Changeset 23594
- Timestamp:
- Mar 29, 2009, 6:15:31 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 6 deleted
- 313 edited
- 114 copied
-
. (modified) (1 prop)
-
Nebulous-Server/Changes (modified) (1 diff)
-
Nebulous-Server/bin/neb-admin (modified) (2 diffs)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (9 diffs)
-
Nebulous/scripts/stats.pl (modified) (2 diffs)
-
Ohana (modified) (1 prop)
-
Ohana/src/libohana/src/IOBufferOps.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.basic/break.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.basic/run_if.c (modified) (1 diff)
-
Ohana/src/opihi/dimm/camera_cmds.c (modified) (1 prop)
-
Ohana/src/opihi/dimm/telescope_cmds.c (modified) (1 prop)
-
Ohana/src/opihi/include/pantasks.h (modified) (3 diffs)
-
Ohana/src/opihi/include/shell.h (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/SocketOps.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/gprint.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/CheckController.c (modified) (9 diffs)
-
Ohana/src/opihi/pantasks/CheckJobs.c (modified) (11 diffs)
-
Ohana/src/opihi/pantasks/CheckPassword.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/CheckTasks.c (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/ControllerOps.c (modified) (11 diffs)
-
Ohana/src/opihi/pantasks/InputQueue.c (modified) (6 diffs)
-
Ohana/src/opihi/pantasks/JobIDOps.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/JobOps.c (modified) (5 diffs)
-
Ohana/src/opihi/pantasks/ListenClients.c (modified) (13 diffs)
-
Ohana/src/opihi/pantasks/LocalJob.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/Makefile (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/controller.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/controller_host.c (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/controller_jobstack.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/controller_status.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/controller_threads.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/controller_verbose.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/delete.c (modified) (5 diffs)
-
Ohana/src/opihi/pantasks/flush.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/init.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/init_server.c (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/jobs_and_tasks_thread.c (copied) (copied from trunk/Ohana/src/opihi/pantasks/jobs_and_tasks_thread.c )
-
Ohana/src/opihi/pantasks/kill.c (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/notes.txt (modified) (1 diff)
-
Ohana/src/opihi/pantasks/pantasks.c.in (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/pantasks_server.c.in (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/server.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/server_run.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/showtask.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/status_server.c (modified) (7 diffs)
-
Ohana/src/opihi/pantasks/task.c (modified) (4 diffs)
-
Ohana/src/opihi/pantasks/task_active.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/task_command.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/task_host.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/task_macros.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/task_nmax.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/task_options.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/task_periods.c (modified) (3 diffs)
-
Ohana/src/opihi/pantasks/task_stdout.c (modified) (6 diffs)
-
Ohana/src/opihi/pantasks/task_trange.c (modified) (5 diffs)
-
Ohana/src/opihi/pantasks/test/threadload.sh (copied) (copied from trunk/Ohana/src/opihi/pantasks/test/threadload.sh )
-
Ohana/src/opihi/pantasks/test/threadload2.sh (copied) (copied from trunk/Ohana/src/opihi/pantasks/test/threadload2.sh )
-
Ohana/src/opihi/pantasks/thread_locks.c (modified) (1 diff)
-
Ohana/src/opihi/pcontrol/JobID.c (deleted)
-
Ohana/src/opihi/pcontrol/JobOps.c (modified) (2 diffs)
-
Ohana/src/opihi/pcontrol/QueueOps.c (deleted)
-
Ohana/src/opihi/pcontrol/ResetJob.c (deleted)
-
Ohana/src/opihi/pcontrol/job.c (modified) (3 diffs)
-
Ohana/src/opihi/pcontrol/stop.c (deleted)
-
Ohana/src/relastro/src/ImageOps.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (1 diff)
-
Ohana/src/relastro/src/bcatalog.c (modified) (6 diffs)
-
PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (10 diffs)
-
dbconfig/changes.txt (modified) (2 diffs)
-
dbconfig/chip.md (modified) (1 diff)
-
dbconfig/config.md (modified) (1 diff)
-
dbconfig/diff.md (modified) (1 diff)
-
dbconfig/dist.md (modified) (2 diffs)
-
dbconfig/ipp.m4 (modified) (1 diff)
-
dbconfig/magic.md (modified) (3 diffs)
-
dbconfig/tasks.md (modified) (2 diffs)
-
dbconfig/warp.md (modified) (1 diff)
-
extsrc (copied) (copied from trunk/extsrc )
-
extsrc/Makefile (copied) (copied from trunk/extsrc/Makefile )
-
extsrc/gpcsw (copied) (copied from trunk/extsrc/gpcsw )
-
extsrc/gpcsw/Make.Common.fixed (copied) (copied from trunk/extsrc/gpcsw/Make.Common.fixed )
-
extsrc/gpcsw/Makefile.in (copied) (copied from trunk/extsrc/gpcsw/Makefile.in )
-
extsrc/gpcsw/autogen.sh (copied) (copied from trunk/extsrc/gpcsw/autogen.sh )
-
extsrc/gpcsw/config.tools (copied) (copied from trunk/extsrc/gpcsw/config.tools )
-
extsrc/gpcsw/configure (copied) (copied from trunk/extsrc/gpcsw/configure )
-
extsrc/gpcsw/configure.tcsh (copied) (copied from trunk/extsrc/gpcsw/configure.tcsh )
-
extsrc/gpcsw/gpcsrc (copied) (copied from trunk/extsrc/gpcsw/gpcsrc )
-
extsrc/gpcsw/gpcsrc/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/Make.Common )
-
extsrc/gpcsw/gpcsrc/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/Makefile )
-
extsrc/gpcsw/gpcsrc/ThisIsTopLevel (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/ThisIsTopLevel )
-
extsrc/gpcsw/gpcsrc/analysis (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis )
-
extsrc/gpcsw/gpcsrc/analysis/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/Make.Common )
-
extsrc/gpcsw/gpcsrc/analysis/libpscoords (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords )
-
extsrc/gpcsw/gpcsrc/analysis/libpscoords/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords/Make.Common )
-
extsrc/gpcsw/gpcsrc/analysis/libpscoords/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords/Makefile )
-
extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.c )
-
extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpscoords/pscoords.h )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/Make.Common )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/Makefile )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.c )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf.h )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psf2dim.f (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psf2dim.f )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psfdonut.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psfdonut.c )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psfmargin.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psfmargin.c )
-
extsrc/gpcsw/gpcsrc/analysis/libpsf/psfmoment.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/analysis/libpsf/psfmoment.c )
-
extsrc/gpcsw/gpcsrc/fits (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits )
-
extsrc/gpcsw/gpcsrc/fits/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/Make.Common )
-
extsrc/gpcsw/gpcsrc/fits/burntool (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool )
-
extsrc/gpcsw/gpcsrc/fits/burntool/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/Make.Common )
-
extsrc/gpcsw/gpcsrc/fits/burntool/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/Makefile )
-
extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/burnparams.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnparams.h )
-
extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h )
-
extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/cheapfits.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/cheapfits.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/fitstable.spec (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/fitstable.spec )
-
extsrc/gpcsw/gpcsrc/fits/burntool/man (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/man )
-
extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1 (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1 )
-
extsrc/gpcsw/gpcsrc/fits/burntool/persistfix.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/persistfix.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/psfstats.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/psfstats.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/sort.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/sort.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c )
-
extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c )
-
extsrc/gpcsw/gpcsrc/fits/libfh (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh )
-
extsrc/gpcsw/gpcsrc/fits/libfh/FHRealTime (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/FHRealTime )
-
extsrc/gpcsw/gpcsrc/fits/libfh/Index (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/Index )
-
extsrc/gpcsw/gpcsrc/fits/libfh/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/Make.Common )
-
extsrc/gpcsw/gpcsrc/fits/libfh/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/Makefile )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh.c )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh.h )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.asm (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.asm )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.h )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.h.new (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.h.new )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry_detcom_notes (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry_detcom_notes )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry_to_asm.sh (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry_to_asm.sh )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_rt.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_rt.c )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_rt.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_rt.h )
-
extsrc/gpcsw/gpcsrc/fits/libfh/fh_validate.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/fh_validate.c )
-
extsrc/gpcsw/gpcsrc/fits/libfh/tests (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/tests )
-
extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.c )
-
extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.log (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.log )
-
extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.sh (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfh/tests/t.sh )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/Index (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/Index )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/Make.Common (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/Make.Common )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/Makefile (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/Makefile )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/dummy.c (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/dummy.c )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/general.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/general.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_all.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_all.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_detector.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_detector.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_instrument.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_instrument.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_otguide.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_otguide.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_plant.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_plant.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_shutter.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_shutter.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_telescope.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_telescope.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_wcs.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/gpc_wcs.h )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/junk (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/junk )
-
extsrc/gpcsw/gpcsrc/fits/libfhreg/macros.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/fits/libfhreg/macros.h )
-
extsrc/gpcsw/gpcsrc/missing_protos.h (copied) (copied from trunk/extsrc/gpcsw/gpcsrc/missing_protos.h )
-
glueforge/templates/psdb/configure_ac.tt (modified) (2 diffs)
-
ippMonitor/raw/ipp.php (modified) (1 diff)
-
ippScripts/scripts/chip_imfile.pl (modified) (7 diffs)
-
ippScripts/scripts/detrend_norm_apply.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_norm_calc.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_process_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_resid_exp.pl (modified) (2 diffs)
-
ippScripts/scripts/detrend_resid_imfile.pl (modified) (2 diffs)
-
ippScripts/scripts/detrend_stack.pl (modified) (2 diffs)
-
ippScripts/scripts/diff_skycell.pl (modified) (9 diffs)
-
ippScripts/scripts/dist_component.pl (modified) (11 diffs)
-
ippScripts/scripts/register_imfile.pl (modified) (3 diffs)
-
ippScripts/scripts/stack_skycell.pl (modified) (1 diff)
-
ippScripts/scripts/summit_copy.pl (modified) (3 diffs)
-
ippScripts/scripts/warp_skycell.pl (modified) (3 diffs)
-
ippTasks/Makefile.am (modified) (3 diffs)
-
ippTasks/chip.pro (modified) (3 diffs)
-
ippTasks/detrend.cleanup.pro (copied) (copied from trunk/ippTasks/detrend.cleanup.pro )
-
ippTasks/detrend.mkruns.pro (deleted)
-
ippTasks/detrend.norm.pro (modified) (7 diffs)
-
ippTasks/detrend.process.pro (modified) (6 diffs)
-
ippTasks/detrend.resid.pro (modified) (6 diffs)
-
ippTasks/detrend.stack.pro (modified) (5 diffs)
-
ippTasks/dist.pro (modified) (2 diffs)
-
ippTasks/nebulous.site.pro.in (modified) (1 diff)
-
ippTasks/pantasks.pro (modified) (1 diff)
-
ippTasks/replicate.pro (modified) (4 diffs)
-
ippTasks/simtest.ctemask.auto (copied) (copied from trunk/ippTasks/simtest.ctemask.auto )
-
ippTasks/simtest.ctemask.config (copied) (copied from trunk/ippTasks/simtest.ctemask.config )
-
ippTasks/simtest.pro (modified) (2 diffs)
-
ippTasks/summit.copy.pro (modified) (6 diffs)
-
ippTasks/warp.pro (modified) (2 diffs)
-
ippTools/configure.ac (modified) (1 diff)
-
ippTools/share/Makefile.am (modified) (3 diffs)
-
ippTools/share/camtool_find_processedexp.sql (modified) (1 diff)
-
ippTools/share/chiptool_change_imfile_data_state.sql (modified) (1 diff)
-
ippTools/share/chiptool_completely_processed_exp.sql (modified) (1 diff)
-
ippTools/share/chiptool_pendingimfile.sql (modified) (1 diff)
-
ippTools/share/difftool_completed_runs.sql (modified) (1 diff)
-
ippTools/share/difftool_definewarpwarp_insert.sql (copied) (copied from trunk/ippTools/share/difftool_definewarpwarp_insert.sql )
-
ippTools/share/difftool_definewarpwarp_select.sql (copied) (copied from trunk/ippTools/share/difftool_definewarpwarp_select.sql )
-
ippTools/share/difftool_inputskyfile.sql (modified) (4 diffs)
-
ippTools/share/disttool_definebyquery_select.sql (copied) (copied from trunk/ippTools/share/disttool_definebyquery_select.sql )
-
ippTools/share/disttool_pendingcomponent.sql (modified) (9 diffs)
-
ippTools/share/magicdstool_completed_runs.sql (modified) (4 diffs)
-
ippTools/share/magicdstool_todestreak.sql (modified) (4 diffs)
-
ippTools/share/magictool_addmask.sql (modified) (1 diff)
-
ippTools/share/magictool_chipprocessedimfile.sql (modified) (1 diff)
-
ippTools/share/magictool_diffskyfile.sql (modified) (1 diff)
-
ippTools/share/magictool_inputskyfile.sql (modified) (1 diff)
-
ippTools/share/magictool_mask.sql (modified) (1 diff)
-
ippTools/share/magictool_rawimfile.sql (modified) (1 diff)
-
ippTools/share/magictool_tomask.sql (modified) (1 diff)
-
ippTools/share/magictool_toprocess_inputs.sql (modified) (1 diff)
-
ippTools/share/magictool_toprocess_tree.sql (modified) (1 diff)
-
ippTools/share/magictool_toskyfilemask.sql (modified) (1 diff)
-
ippTools/share/magictool_totree.sql (modified) (1 diff)
-
ippTools/share/magictool_warpskyfile.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (7 diffs)
-
ippTools/share/pxadmin_drop_tables.sql (modified) (2 diffs)
-
ippTools/share/pztool_find_completed_exp.sql (modified) (1 diff)
-
ippTools/share/regtool_updateprocessedimfile.sql (copied) (copied from trunk/ippTools/share/regtool_updateprocessedimfile.sql )
-
ippTools/share/warptool_change_skyfile_data_state.sql (modified) (1 diff)
-
ippTools/share/warptool_definebyquery.sql (modified) (1 diff)
-
ippTools/share/warptool_finish_run.sql (copied) (copied from trunk/ippTools/share/warptool_finish_run.sql )
-
ippTools/share/warptool_finished_run_select.sql (copied) (copied from trunk/ippTools/share/warptool_finished_run_select.sql )
-
ippTools/share/warptool_pendingcleanuprun.sql (modified) (1 diff)
-
ippTools/share/warptool_pendingcleanupskyfile.sql (modified) (1 diff)
-
ippTools/share/warptool_towarped.sql (modified) (1 diff)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/Makefile.am (modified) (3 diffs)
-
ippTools/src/camtool.c (modified) (8 diffs)
-
ippTools/src/camtoolConfig.c (modified) (5 diffs)
-
ippTools/src/chiptool.c (modified) (8 diffs)
-
ippTools/src/chiptoolConfig.c (modified) (3 diffs)
-
ippTools/src/difftool.c (modified) (35 diffs)
-
ippTools/src/difftool.h (modified) (1 diff)
-
ippTools/src/difftoolConfig.c (modified) (3 diffs)
-
ippTools/src/disttool.c (modified) (5 diffs)
-
ippTools/src/disttoolConfig.c (modified) (2 diffs)
-
ippTools/src/magicdstool.c (modified) (12 diffs)
-
ippTools/src/magicdstoolConfig.c (modified) (2 diffs)
-
ippTools/src/magictool.c (modified) (4 diffs)
-
ippTools/src/pxcam.c (modified) (2 diffs)
-
ippTools/src/pxchip.c (modified) (6 diffs)
-
ippTools/src/pxchip.h (modified) (1 diff)
-
ippTools/src/pxerrors.c (modified) (2 diffs)
-
ippTools/src/pxtools.h (modified) (8 diffs)
-
ippTools/src/pxwarp.c (modified) (2 diffs)
-
ippTools/src/pxwarp.h (modified) (1 diff)
-
ippTools/src/pztool.c (modified) (11 diffs)
-
ippTools/src/pztool.h (modified) (1 diff)
-
ippTools/src/pztoolConfig.c (modified) (3 diffs)
-
ippTools/src/regtool.c (modified) (11 diffs)
-
ippTools/src/regtoolConfig.c (modified) (4 diffs)
-
ippTools/src/warptool.c (modified) (13 diffs)
-
ippTools/src/warptoolConfig.c (modified) (5 diffs)
-
ippconfig/gpc1/ppImage.config (modified) (1 diff)
-
ippconfig/recipes/Makefile.am (modified) (1 diff)
-
ippconfig/recipes/filerules-mef.mdc (modified) (3 diffs)
-
ippconfig/recipes/filerules-simple.mdc (modified) (4 diffs)
-
ippconfig/recipes/filerules-split.mdc (modified) (4 diffs)
-
ippconfig/recipes/jpeg.mdc (modified) (1 diff)
-
ippconfig/recipes/masks.16bit.config (modified) (1 diff)
-
ippconfig/recipes/masks.config (modified) (2 diffs)
-
ippconfig/recipes/ppImage.config (modified) (4 diffs)
-
ippconfig/recipes/ppMerge.config (modified) (2 diffs)
-
ippconfig/recipes/ppSim.config (modified) (2 diffs)
-
ippconfig/recipes/ppStack.config (modified) (1 diff)
-
ippconfig/recipes/ppSub.config (modified) (1 diff)
-
ippconfig/recipes/psastro.config (modified) (1 diff)
-
ippconfig/recipes/reductionClasses.mdc (modified) (1 diff)
-
ippconfig/recipes/rejections.config (modified) (1 diff)
-
ippconfig/system.config (modified) (1 diff)
-
operations/registration/input (modified) (2 diffs)
-
operations/registration/ptolemy.rc (modified) (1 diff)
-
ppImage (modified) (1 prop)
-
ppImage/src/ppImageCheckCTE.c (copied) (copied from trunk/ppImage/src/ppImageCheckCTE.c )
-
ppImage/src/ppImageCheckCTE.v1.c (copied) (copied from trunk/ppImage/src/ppImageCheckCTE.v1.c )
-
ppMerge/src/Makefile.am (modified) (1 diff)
-
ppMerge/src/ppMerge.c (modified) (1 diff)
-
ppMerge/src/ppMerge.h (modified) (1 diff)
-
ppMerge/src/ppMergeArguments.c (modified) (3 diffs)
-
ppMerge/src/ppMergeCamera.c (modified) (1 diff)
-
ppMerge/src/ppMergeFiles.c (modified) (1 diff)
-
ppMerge/src/ppMergeLoop.c (copied) (copied from trunk/ppMerge/src/ppMergeLoop.c )
-
ppMerge/src/ppMergeLoop_Threaded.c (deleted)
-
ppMerge/src/ppMergeScaleZero.c (modified) (1 diff)
-
ppSim/src/Makefile.am (modified) (1 diff)
-
ppSim/src/ppSim.h (modified) (3 diffs)
-
ppSim/src/ppSimBadCTE.c (copied) (copied from trunk/ppSim/src/ppSimBadCTE.c )
-
ppSim/src/ppSimLoadSpots.c (modified) (1 diff)
-
ppSim/src/ppSimLoadStars.c (modified) (1 diff)
-
ppSim/src/ppSimLoop.c (modified) (1 diff)
-
ppSim/src/ppSimRandomGaussian.c (modified) (6 diffs)
-
ppSim/src/ppSimStars.c (modified) (2 diffs)
-
ppStack (modified) (1 prop)
-
ppStack/src/Makefile.am (modified) (1 diff)
-
ppStack/src/ppStack.h (modified) (3 diffs)
-
ppStack/src/ppStackArguments.c (modified) (5 diffs)
-
ppStack/src/ppStackCamera.c (modified) (3 diffs)
-
ppStack/src/ppStackCombineInitial.c (modified) (4 diffs)
-
ppStack/src/ppStackCombinePrepare.c (copied) (copied from trunk/ppStack/src/ppStackCombinePrepare.c )
-
ppStack/src/ppStackConvolve.c (modified) (6 diffs)
-
ppStack/src/ppStackFiles.c (modified) (1 diff)
-
ppStack/src/ppStackFinish.c (modified) (1 diff)
-
ppStack/src/ppStackLoop.c (modified) (2 diffs)
-
ppStack/src/ppStackLoop.h (modified) (2 diffs)
-
ppStack/src/ppStackMatch.c (modified) (13 diffs)
-
ppStack/src/ppStackOptions.c (modified) (3 diffs)
-
ppStack/src/ppStackOptions.h (modified) (2 diffs)
-
ppStack/src/ppStackPhotometry.c (modified) (2 diffs)
-
ppStack/src/ppStackPrepare.c (modified) (3 diffs)
-
ppStack/src/ppStackReadout.c (modified) (5 diffs)
-
ppStack/src/ppStackReject.c (modified) (3 diffs)
-
ppStack/src/ppStackSetup.c (modified) (3 diffs)
-
ppStack/src/ppStackSources.c (modified) (13 diffs)
-
ppStats/src/ppStats.h (modified) (1 diff)
-
ppSub (modified) (1 prop)
-
ppSub/src/ppSubArguments.c (modified) (2 diffs)
-
ppSub/src/ppSubCamera.c (modified) (11 diffs)
-
ppSub/src/ppSubDefineOutput.c (modified) (1 diff)
-
ppSub/src/ppSubMatchPSFs.c (modified) (2 diffs)
-
ppSub/src/ppSubSetMasks.c (modified) (4 diffs)
-
psLib/src/db/psDB.c (modified) (15 diffs)
-
psLib/src/fits/psFitsHeader.c (modified) (1 diff)
-
psLib/src/imageops/psImageBinning.c (modified) (1 diff)
-
psLib/src/imageops/psImageBinning.h (modified) (1 diff)
-
psLib/src/imageops/psImageCovariance.c (modified) (1 diff)
-
psLib/src/jpeg/psImageJpeg.c (modified) (1 diff)
-
psLib/src/jpeg/psImageJpeg.h (modified) (2 diffs)
-
psLib/src/math/psMinimizeLMM.c (modified) (14 diffs)
-
psLib/src/math/psMinimizeLMM.h (modified) (2 diffs)
-
psLib/src/math/psSparse.c (modified) (2 diffs)
-
psLib/src/math/psSpline.c (modified) (5 diffs)
-
psLib/src/math/psSpline.h (modified) (1 diff)
-
psLib/src/math/psStats.c (modified) (1 diff)
-
psLib/src/mathtypes/psImage.c (modified) (2 diffs)
-
psLib/src/sys/psError.c (modified) (2 diffs)
-
psLib/src/sys/psError.h (modified) (1 diff)
-
psLib/src/sys/psLogMsg.c (modified) (1 diff)
-
psLib/src/sys/psLogMsg.h (modified) (2 diffs)
-
psModules (modified) (1 prop)
-
psModules/src/astrom/pmAstrometryDistortion.c (modified) (3 diffs)
-
psModules/src/astrom/pmAstrometryDistortion.h (modified) (1 diff)
-
psModules/src/astrom/pmAstrometryVisual.c (modified) (1 diff)
-
psModules/src/astrom/pmAstrometryVisual.h (modified) (1 diff)
-
psModules/src/camera/pmFPARead.c (modified) (1 diff)
-
psModules/src/camera/pmFPAWrite.c (modified) (3 diffs)
-
psModules/src/camera/pmFPAfile.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfile.h (modified) (1 diff)
-
psModules/src/camera/pmFPAfileDefine.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfileDefine.h (modified) (1 diff)
-
psModules/src/camera/pmFPAfileFitsIO.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileIO.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfileIO.h (modified) (1 diff)
-
psModules/src/concepts/pmConceptsStandard.c (modified) (5 diffs)
-
psModules/src/concepts/pmConceptsWrite.c (modified) (14 diffs)
-
psModules/src/concepts/pmConceptsWrite.h (modified) (4 diffs)
-
psModules/src/config/pmConfig.c (modified) (1 diff)
-
psModules/src/config/pmConfigCamera.c (modified) (2 diffs)
-
psModules/src/config/pmConfigMask.c (modified) (1 diff)
-
psModules/src/config/pmConfigRun.c (modified) (4 diffs)
-
psModules/src/config/pmConfigRun.h (modified) (1 diff)
-
psModules/src/detrend/pmDetrendDB.h (modified) (1 diff)
-
psModules/src/detrend/pmDetrendThreads.h (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.c (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.h (modified) (1 diff)
-
psModules/src/extras/pmKapaPlots.c (modified) (1 diff)
-
psModules/src/extras/pmKapaPlots.h (modified) (2 diffs)
-
psModules/src/extras/psPipe.c (modified) (1 diff)
-
psModules/src/extras/psPipe.h (modified) (2 diffs)
-
psModules/src/imcombine/pmStack.c (modified) (16 diffs)
-
psModules/src/imcombine/pmStack.h (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionIO.c (modified) (3 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.h (modified) (1 diff)
-
psModules/src/objects/pmDetections.c (modified) (1 diff)
-
psModules/src/objects/pmDetections.h (modified) (1 diff)
-
psModules/src/objects/pmMoments.c (modified) (1 diff)
-
psModules/src/objects/pmMoments.h (modified) (1 diff)
-
psModules/src/objects/pmPSF.c (modified) (1 diff)
-
psModules/src/objects/pmPSF.h (modified) (1 diff)
-
psModules/src/objects/pmSource.h (modified) (1 diff)
-
psModules/src/objects/pmSourceExtendedPars.c (modified) (6 diffs)
-
psModules/src/objects/pmSourceExtendedPars.h (modified) (1 diff)
-
psModules/src/objects/pmSourceFitSet.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceFitSet.h (modified) (3 diffs)
-
psModules/src/objects/pmSourcePlots.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePlots.h (modified) (1 diff)
-
psastro (modified) (1 prop)
-
psastro/src (modified) (1 prop)
-
psastro/src/Makefile.am (modified) (2 diffs)
-
psastro/src/psastro.h (modified) (3 diffs)
-
psastro/src/psastroAnalysis.c (modified) (5 diffs)
-
psastro/src/psastroChooseRefstars.c (modified) (2 diffs)
-
psastro/src/psastroExtract.c (copied) (copied from trunk/psastro/src/psastroExtract.c )
-
psastro/src/psastroExtractAnalysis.c (copied) (copied from trunk/psastro/src/psastroExtractAnalysis.c )
-
psastro/src/psastroExtractArguments.c (copied) (copied from trunk/psastro/src/psastroExtractArguments.c )
-
psastro/src/psastroExtractDataLoad.c (copied) (copied from trunk/psastro/src/psastroExtractDataLoad.c )
-
psastro/src/psastroExtractDataSave.c (copied) (copied from trunk/psastro/src/psastroExtractDataSave.c )
-
psastro/src/psastroExtractFindChip.c (copied) (copied from trunk/psastro/src/psastroExtractFindChip.c )
-
psastro/src/psastroExtractGhosts.c (copied) (copied from trunk/psastro/src/psastroExtractGhosts.c )
-
psastro/src/psastroExtractParseCamera.c (copied) (copied from trunk/psastro/src/psastroExtractParseCamera.c )
-
psastro/src/psastroExtractStar.c (copied) (copied from trunk/psastro/src/psastroExtractStar.c )
-
psastro/src/psastroExtractStars.c (copied) (copied from trunk/psastro/src/psastroExtractStars.c )
-
psastro/src/psastroLoadRefstars.c (modified) (4 diffs)
-
psconfig (modified) (1 prop)
-
psconfig/psbuild (modified) (3 diffs)
-
psconfig/psconfig.csh.in (modified) (1 diff)
-
psconfig/tagsets/ipp-2.8.dist (modified) (2 diffs)
-
psphot (modified) (1 prop)
-
psphot/src/psphot.h (modified) (5 diffs)
-
psphot/src/psphotCleanup.c (modified) (1 diff)
-
psphot/src/psphotDetect.h (modified) (1 diff)
-
psphot/src/psphotFitSourcesLinear.c (modified) (5 diffs)
-
psphot/src/psphotMaskReadout.c (modified) (1 diff)
-
psphot/src/psphotReadout.c (modified) (1 diff)
-
psphot/src/psphotReadoutFindPSF.c (modified) (1 diff)
-
psphot/src/psphotReadoutKnownSources.c (modified) (1 diff)
-
psphot/src/psphotReadoutMinimal.c (modified) (1 diff)
-
psphot/src/psphotStandAlone.h (modified) (1 diff)
-
pswarp/src/pswarp.h (modified) (3 diffs)
-
pswarp/src/pswarpMapGrid.c (modified) (9 diffs)
-
pswarp/src/pswarpParseCamera.c (modified) (1 diff)
-
pswarp/src/pswarpSetMaskBits.c (modified) (1 diff)
-
pswarp/src/pswarpSetThreads.c (modified) (1 diff)
-
pswarp/src/pswarpTransformReadout.c (modified) (1 diff)
-
pswarp/src/pswarpTransformTile.c (modified) (1 diff)
-
tools/ipp_apply_burntool.pl (copied) (copied from trunk/tools/ipp_apply_burntool.pl )
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/Changes
r20155 r23594 1 1 Revision history for Nebulous 2 3 0.17 4 - retry database transactions when a deadlock is detected 2 5 3 6 0.16 -
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/bin/neb-admin
r23352 r23594 152 152 153 153 exit unless scalar @rows; 154 155 # compare number of responses to limit below 156 my $Npending = @rows; 154 157 155 158 print "replicatePending MULTI\n\n"; … … 198 201 } 199 202 200 return 1; 203 # use a different exit status if we hit the limit (likely more files pending) 204 if ($Npending == $limit) { 205 exit 1; 206 } 207 exit 0; 201 208 } 202 203 209 204 210 sub removal -
branches/cnb_branches/cnb_branch_20090301/Nebulous-Server/lib/Nebulous/Server.pm
r20990 r23594 163 163 164 164 my $uri; 165 eval { 166 { 167 # create storage_object 168 my $query = $db->prepare_cached( $sql->new_object ); 169 $query->execute('NULL', $key->path); 170 } 171 172 my $so_id; 173 { 174 # get object ID 175 my $query = $db->prepare_cached( $sql->last_insert_id ); 176 $query->execute; 177 ($so_id) = $query->fetchrow_array; 178 # XXX finish seems to be required when using LAST_INSERT_ID() or we 179 # get a warning about the stmt handling still be active the next 180 # time LAST_INSERT_ID() is invoked 181 $query->finish; 182 } 183 184 { 185 # create storage_object_attr 186 my $query = $db->prepare_cached( $sql->new_object_attr ); 187 $query->execute($so_id); 188 } 189 190 { 191 192 # create instance with no URI 165 TRANS: while (1) { 166 eval { 167 { 168 # create storage_object 169 my $query = $db->prepare_cached( $sql->new_object ); 170 $query->execute('NULL', $key->path); 171 } 172 173 my $so_id; 174 { 175 # get object ID 176 my $query = $db->prepare_cached( $sql->last_insert_id ); 177 $query->execute; 178 ($so_id) = $query->fetchrow_array; 179 # XXX finish seems to be required when using LAST_INSERT_ID() or we 180 # get a warning about the stmt handling still be active the next 181 # time LAST_INSERT_ID() is invoked 182 $query->finish; 183 } 184 185 { 186 # create storage_object_attr 187 my $query = $db->prepare_cached( $sql->new_object_attr ); 188 $query->execute($so_id); 189 } 190 191 { 192 193 # create instance with no URI 193 194 # my $query = $db->prepare_cached( $sql->new_instance ); 194 my $query = $db->prepare_cached( $sql->new_object_instance );195 $query->execute($vol_id);196 }197 198 my $ins_id;199 {200 # get instance ID201 my $query = $db->prepare_cached( $sql->last_insert_id );202 $query->execute;203 ($ins_id) = $query->fetchrow_array;204 # XXX finish seems to be required when using LAST_INSERT_ID() or we205 # get a warning about the stmt handling still be active the next206 # time LAST_INSERT_ID() is invoked207 $query->finish;208 }209 210 # Unfortunately, since we want to use the instance row's ID as part of the211 # actual on disk file name we can't try to create the file until after212 # we've create both a new storage_storage object and instance.213 214 # TODO add some stuff here to retry if unsucessful215 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr);216 $log->debug("created $uri on volume ID: $vol_id");217 218 {219 # update the instance with URI & vol_id that the file is on220 my $query = $db->prepare_cached( $sql->update_instance_uri );221 # vol_id, uri, ins_id222 $query->execute($vol_id, "$uri", $ins_id);223 }224 225 $db->commit;226 $log->debug("commit");227 };228 if ($@) {195 my $query = $db->prepare_cached( $sql->new_object_instance ); 196 $query->execute($vol_id); 197 } 198 199 my $ins_id; 200 { 201 # get instance ID 202 my $query = $db->prepare_cached( $sql->last_insert_id ); 203 $query->execute; 204 ($ins_id) = $query->fetchrow_array; 205 # XXX finish seems to be required when using LAST_INSERT_ID() or we 206 # get a warning about the stmt handling still be active the next 207 # time LAST_INSERT_ID() is invoked 208 $query->finish; 209 } 210 211 # Unfortunately, since we want to use the instance row's ID as part of the 212 # actual on disk file name we can't try to create the file until after 213 # we've create both a new storage_storage object and instance. 214 215 # TODO add some stuff here to retry if unsucessful 216 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr); 217 $log->debug("created $uri on volume ID: $vol_id"); 218 219 { 220 # update the instance with URI & vol_id that the file is on 221 my $query = $db->prepare_cached( $sql->update_instance_uri ); 222 # vol_id, uri, ins_id 223 $query->execute($vol_id, "$uri", $ins_id); 224 } 225 226 $db->commit; 227 $log->debug("commit"); 228 }; 229 if ($@) { 229 230 # and not $key->soft_volume 230 $db->rollback; 231 $log->debug("rollback"); 232 $log->logdie("error: $@"); 231 $db->rollback; 232 $log->debug("rollback"); 233 if ($@ =~ /Deadlock found/) { 234 $log->warn("database deadlock retrying transaction: $@"); 235 redo TRANS; 236 } 237 $log->logdie("error: $@"); 238 } 239 last; 233 240 } 234 241 … … 269 276 $newkey = parse_neb_key($newkey); 270 277 271 eval { 272 # rename storage_object 273 my $query = $db->prepare_cached($sql->rename_object); 274 # this SQL statment takes the new key name as the first param 275 my $rows = $query->execute($newkey->path, $key->path); 276 277 # if we affected more then one row something very bad has happened. 278 unless ($rows == 1) { 279 $query->finish; 280 $log->logdie("affected row count is $rows instead of 1"); 281 } 282 283 $db->commit; 284 $log->debug("commit"); 285 }; 286 if ($@) { 287 $db->rollback; 288 $log->debug("rollback"); 289 $log->logdie("database error: $@"); 290 } 278 TRANS: while (1) { 279 eval { 280 # rename storage_object 281 my $query = $db->prepare_cached($sql->rename_object); 282 # this SQL statment takes the new key name as the first param 283 my $rows = $query->execute($newkey->path, $key->path); 284 285 # if we affected more then one row something very bad has happened. 286 unless ($rows == 1) { 287 $query->finish; 288 $log->logdie("affected row count is $rows instead of 1"); 289 } 290 291 $db->commit; 292 $log->debug("commit"); 293 }; 294 if ($@) { 295 $db->rollback; 296 $log->debug("rollback"); 297 if ($@ =~ /Deadlock found/) { 298 $log->warn("database deadlock retrying transaction: $@"); 299 redo TRANS; 300 } 301 $log->logdie("database error: $@"); 302 } 303 last; 304 } 291 305 292 306 $log->debug("leaving"); … … 330 344 # key1.swap -> key2 331 345 332 eval { 333 { 334 # key1 -> key1.swap 335 my $query = $db->prepare_cached($sql->rename_object); 336 # this SQL statment takes the new key name as the first param 337 my $rows = $query->execute($key1->path . ".swap", $key1->path); 338 339 # if we affected more then one row something very bad has happened. 340 unless ($rows == 1) { 341 $query->finish; 342 $log->logdie("affected row count is $rows instead of 1"); 343 } 344 } 345 346 { 347 # key2 -> key1 348 my $query = $db->prepare_cached($sql->rename_object); 349 # this SQL statment takes the new key name as the first param 350 my $rows = $query->execute($key1->path, $key2->path); 351 352 # if we affected more then one row something very bad has happened. 353 unless ($rows == 1) { 354 $query->finish; 355 $log->logdie("affected row count is $rows instead of 1"); 356 } 357 } 358 359 { 360 # key1.swap -> key2 361 my $query = $db->prepare_cached($sql->rename_object); 362 # this SQL statment takes the new key name as the first param 363 my $rows = $query->execute($key2->path, $key1->path . ".swap"); 364 365 # if we affected more then one row something very bad has happened. 366 unless ($rows == 1) { 367 $query->finish; 368 $log->logdie("affected row count is $rows instead of 1"); 369 } 370 } 371 372 $db->commit; 373 $log->debug("commit"); 374 }; 375 if ($@) { 376 $db->rollback; 377 $log->debug("rollback"); 378 $log->logdie("database error: $@"); 346 TRANS: while (1) { 347 eval { 348 { 349 # key1 -> key1.swap 350 my $query = $db->prepare_cached($sql->rename_object); 351 # this SQL statment takes the new key name as the first param 352 my $rows = $query->execute($key1->path . ".swap", $key1->path); 353 354 # if we affected more then one row something very bad has happened. 355 unless ($rows == 1) { 356 $query->finish; 357 $log->logdie("affected row count is $rows instead of 1"); 358 } 359 } 360 361 { 362 # key2 -> key1 363 my $query = $db->prepare_cached($sql->rename_object); 364 # this SQL statment takes the new key name as the first param 365 my $rows = $query->execute($key1->path, $key2->path); 366 367 # if we affected more then one row something very bad has happened. 368 unless ($rows == 1) { 369 $query->finish; 370 $log->logdie("affected row count is $rows instead of 1"); 371 } 372 } 373 374 { 375 # key1.swap -> key2 376 my $query = $db->prepare_cached($sql->rename_object); 377 # this SQL statment takes the new key name as the first param 378 my $rows = $query->execute($key2->path, $key1->path . ".swap"); 379 380 # if we affected more then one row something very bad has happened. 381 unless ($rows == 1) { 382 $query->finish; 383 $log->logdie("affected row count is $rows instead of 1"); 384 } 385 } 386 387 $db->commit; 388 $log->debug("commit"); 389 }; 390 if ($@) { 391 $db->rollback; 392 $log->debug("rollback"); 393 if ($@ =~ /Deadlock found/) { 394 $log->warn("database deadlock retrying transaction: $@"); 395 redo TRANS; 396 } 397 $log->logdie("database error: $@"); 398 } 399 last; 379 400 } 380 401 … … 448 469 449 470 my $uri; 450 eval { 451 my $so_id; 452 { 453 # verify that at least one instance is currently available 454 my $query = $db->prepare_cached( $sql->get_object_instances ); 455 my $rows = $query->execute($key->path, 1); 456 457 unless ( $rows > 0 ) { 471 TRANS: while (1) { 472 eval { 473 my $so_id; 474 { 475 # verify that at least one instance is currently available 476 my $query = $db->prepare_cached( $sql->get_object_instances ); 477 my $rows = $query->execute($key->path, 1); 478 479 unless ( $rows > 0 ) { 480 $query->finish; 481 $log->logdie( "storage object does not exist" ); 482 } 483 484 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 458 485 $query->finish; 459 $log->logdie( "storage object does not exist" ); 460 } 461 462 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 463 $query->finish; 464 } 465 466 { 467 my $query = $db->prepare_cached( $sql->new_instance ); 468 $query->execute($so_id, $vol_id); 469 } 470 471 my $ins_id; 472 { 473 my $query = $db->prepare_cached( $sql->last_insert_id ); 474 $query->execute(); 475 ($ins_id) = $query->fetchrow_array; 476 # XXX finish seems to be required when using LAST_INSERT_ID() or we 477 # get a warning about the stmt handling still being active the next 478 # time LAST_INSERT_ID() is invoked 479 $query->finish; 480 } 481 482 # Unfortunately, since we want to use the instance row's ID as part of 483 # the actual on disk file name we can't try to create the file until 484 # after we've create both a new storage_storage object and instance. 485 486 # TODO add some stuff here to retry if unsucessful 487 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr); 488 489 { 490 my $query = $db->prepare_cached( $sql->update_instance_uri ); 491 # vol_id, uri, ins_id 492 $query->execute($vol_id, $uri, $ins_id); 493 } 494 495 $db->commit; 496 $log->debug("commit"); 497 }; 498 if ($@) { 499 $db->rollback; 500 # handle soft volumes 501 if (defined $vol_name and defined $key->soft_volume) { 502 $log->debug("retrying with 'any' volume"); 503 return $self->replicate_object($key->path, 'any'); 504 } 505 $log->debug("rollback"); 506 $log->logdie("error: $@"); 486 } 487 488 { 489 my $query = $db->prepare_cached( $sql->new_instance ); 490 $query->execute($so_id, $vol_id); 491 } 492 493 my $ins_id; 494 { 495 my $query = $db->prepare_cached( $sql->last_insert_id ); 496 $query->execute(); 497 ($ins_id) = $query->fetchrow_array; 498 # XXX finish seems to be required when using LAST_INSERT_ID() or we 499 # get a warning about the stmt handling still being active the next 500 # time LAST_INSERT_ID() is invoked 501 $query->finish; 502 } 503 504 # Unfortunately, since we want to use the instance row's ID as part of 505 # the actual on disk file name we can't try to create the file until 506 # after we've create both a new storage_storage object and instance. 507 508 # TODO add some stuff here to retry if unsucessful 509 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr); 510 511 { 512 my $query = $db->prepare_cached( $sql->update_instance_uri ); 513 # vol_id, uri, ins_id 514 $query->execute($vol_id, $uri, $ins_id); 515 } 516 517 $db->commit; 518 $log->debug("commit"); 519 }; 520 if ($@) { 521 $db->rollback; 522 # handle soft volumes 523 if (defined $vol_name and defined $key->soft_volume) { 524 $log->debug("retrying with 'any' volume"); 525 return $self->replicate_object($key->path, 'any'); 526 } 527 $log->debug("rollback"); 528 if ($@ =~ /Deadlock found/) { 529 $log->warn("database deadlock retrying transaction: $@"); 530 redo TRANS; 531 } 532 $log->logdie("error: $@"); 533 } 534 last; 507 535 } 508 536 … … 545 573 my $write_lock; 546 574 547 eval { 548 { 549 # this will set update locks 550 my $query = $db->prepare_cached( $sql->get_object_locks ); 551 my $rows = $query->execute( $key->path ); 552 unless ( $rows == 1 ) { 575 TRANS: while (1) { 576 eval { 577 { 578 # this will set update locks 579 my $query = $db->prepare_cached( $sql->get_object_locks ); 580 my $rows = $query->execute( $key->path ); 581 unless ( $rows == 1 ) { 582 $query->finish; 583 $log->logdie( "storage object does not exist" ); 584 } 585 586 my $row = $query->fetchrow_hashref; 553 587 $query->finish; 554 $log->logdie( "storage object does not exist" ); 555 } 556 557 my $row = $query->fetchrow_hashref; 558 $query->finish; 559 560 $so_id = $row->{ 'so_id' }; 561 $read_lock = $row->{ 'read_lock' }; 562 $write_lock = $row->{ 'write_lock' }; 563 } 564 565 if ($type eq 'write') { 566 # can't set a write lock twice and 567 # can't set a write lock if there are read locks 568 if ($write_lock) { 569 $log->logdie("can not write lock twice -- retry"); 570 } 571 572 if ($read_lock > 0) { 573 $log->logdie("can not write lock after read lock -- retry"); 574 } 575 576 { 577 my $query = $db->prepare_cached( $sql->set_write_lock ); 578 my $rows = $query->execute($key->path); 579 580 # if we affected more then one row something very bad has happened. 581 unless ($rows == 1) { 582 $log->logdie("affected row count is $rows instead of 1"); 583 } 584 585 } 586 } elsif ($type eq 'read') { 587 # can't set a read lock if there's a write lock 588 if ($write_lock) { 589 $log->logdie("can not read lock after write lock -- retry"); 590 } 591 592 { 593 my $query = $db->prepare_cached( $sql->increment_read_lock ); 594 my $rows = $query->execute($key->path); 595 596 # if we affected more then one row something very bad has happened. 597 unless ($rows == 1) { 598 $log->logdie("affected row count is $rows instead of 1"); 599 } 600 } 601 } 602 603 $db->commit; 604 $log->debug("commit"); 605 }; 606 if ($@) { 607 $db->rollback; 608 $log->debug("rollback"); 609 $log->logdie("error: $@"); 588 589 $so_id = $row->{ 'so_id' }; 590 $read_lock = $row->{ 'read_lock' }; 591 $write_lock = $row->{ 'write_lock' }; 592 } 593 594 if ($type eq 'write') { 595 # can't set a write lock twice and 596 # can't set a write lock if there are read locks 597 if ($write_lock) { 598 $log->logdie("can not write lock twice -- retry"); 599 } 600 601 if ($read_lock > 0) { 602 $log->logdie("can not write lock after read lock -- retry"); 603 } 604 605 { 606 my $query = $db->prepare_cached( $sql->set_write_lock ); 607 my $rows = $query->execute($key->path); 608 609 # if we affected more then one row something very bad has happened. 610 unless ($rows == 1) { 611 $log->logdie("affected row count is $rows instead of 1"); 612 } 613 614 } 615 } elsif ($type eq 'read') { 616 # can't set a read lock if there's a write lock 617 if ($write_lock) { 618 $log->logdie("can not read lock after write lock -- retry"); 619 } 620 621 { 622 my $query = $db->prepare_cached( $sql->increment_read_lock ); 623 my $rows = $query->execute($key->path); 624 625 # if we affected more then one row something very bad has happened. 626 unless ($rows == 1) { 627 $log->logdie("affected row count is $rows instead of 1"); 628 } 629 } 630 } 631 632 $db->commit; 633 $log->debug("commit"); 634 }; 635 if ($@) { 636 $db->rollback; 637 $log->debug("rollback"); 638 if ($@ =~ /Deadlock found/) { 639 $log->warn("database deadlock retrying transaction: $@"); 640 redo TRANS; 641 } 642 $log->logdie("error: $@"); 643 } 644 last; 610 645 } 611 646 … … 648 683 my $write_lock; 649 684 650 eval { 651 { 652 # this will set update locks 653 my $query = $db->prepare_cached( $sql->get_object_locks ); 654 my $rows = $query->execute($key->path); 655 unless ($rows == 1) { 685 TRANS: while (1) { 686 eval { 687 { 688 # this will set update locks 689 my $query = $db->prepare_cached( $sql->get_object_locks ); 690 my $rows = $query->execute($key->path); 691 unless ($rows == 1) { 692 $query->finish; 693 $log->logdie("storage object does not exist"); 694 } 695 696 my $row = $query->fetchrow_hashref; 656 697 $query->finish; 657 $log->logdie("storage object does not exist"); 658 } 659 660 my $row = $query->fetchrow_hashref; 661 $query->finish; 662 663 $so_id = $row->{ 'so_id' }; 664 $read_lock = $row->{ 'read_lock' }; 665 $write_lock = $row->{ 'write_lock' }; 666 } 667 668 if ($type eq 'write') { 669 # can't remove a write lock if it doesn't exist 670 if ($read_lock) { 671 $log->logdie("can not have a write lock under a read lock"); 672 } 673 674 unless ($write_lock) { 675 $log->logdie("can not remove non-existant write lock"); 676 } 677 678 { 679 my $query = $db->prepare_cached( $sql->delete_write_lock ); 680 my $rows = $query->execute($key->path); 681 682 # if we affected more then one row something very bad has happened. 683 unless ($rows == 1) { 684 $log->logdie("affected row count is $rows instead of 1"); 685 } 686 } 687 } elsif ($type eq 'read') { 688 # can't remove a read lock if there's a write lock and 689 # can't remove a read lock if there aren't any 690 if ($write_lock) { 691 $log->logdie("can not have a read lock under a write lock"); 692 } 693 694 if ($read_lock == 0) { 695 $log->logdie("can not remove non-existant read lock"); 696 } 697 698 { 699 my $query = $db->prepare_cached( $sql->decrement_read_lock ); 700 my $rows = $query->execute($key->path); 701 702 # if we affected more then one row something very bad has happened. 703 unless ($rows == 1) { 704 $log->logdie("affected row count is $rows instead of 1"); 705 } 706 707 } 708 } 709 $db->commit; 710 $log->debug("commit"); 711 }; 712 if ($@) { 713 $db->rollback; 714 $log->debug("rollback"); 715 $log->logdie("error: $@"); 698 699 $so_id = $row->{ 'so_id' }; 700 $read_lock = $row->{ 'read_lock' }; 701 $write_lock = $row->{ 'write_lock' }; 702 } 703 704 if ($type eq 'write') { 705 # can't remove a write lock if it doesn't exist 706 if ($read_lock) { 707 $log->logdie("can not have a write lock under a read lock"); 708 } 709 710 unless ($write_lock) { 711 $log->logdie("can not remove non-existant write lock"); 712 } 713 714 { 715 my $query = $db->prepare_cached( $sql->delete_write_lock ); 716 my $rows = $query->execute($key->path); 717 718 # if we affected more then one row something very bad has happened. 719 unless ($rows == 1) { 720 $log->logdie("affected row count is $rows instead of 1"); 721 } 722 } 723 } elsif ($type eq 'read') { 724 # can't remove a read lock if there's a write lock and 725 # can't remove a read lock if there aren't any 726 if ($write_lock) { 727 $log->logdie("can not have a read lock under a write lock"); 728 } 729 730 if ($read_lock == 0) { 731 $log->logdie("can not remove non-existant read lock"); 732 } 733 734 { 735 my $query = $db->prepare_cached( $sql->decrement_read_lock ); 736 my $rows = $query->execute($key->path); 737 738 # if we affected more then one row something very bad has happened. 739 unless ($rows == 1) { 740 $log->logdie("affected row count is $rows instead of 1"); 741 } 742 743 } 744 } 745 $db->commit; 746 $log->debug("commit"); 747 }; 748 if ($@) { 749 $db->rollback; 750 $log->debug("rollback"); 751 if ($@ =~ /Deadlock found/) { 752 $log->warn("database deadlock retrying transaction: $@"); 753 redo TRANS; 754 } 755 $log->logdie("error: $@"); 756 } 757 last; 716 758 } 717 759 … … 756 798 $key = parse_neb_key($key); 757 799 758 eval { 759 my $query; 760 761 if ($flags eq 'create') { 762 $query = $db->prepare_cached( $sql->new_object_xattr ); 763 } else { 764 # replace 765 $query = $db->prepare_cached( $sql->replace_object_xattr ); 766 } 767 768 # name, value, ext_id 769 my $rows = $query->execute($name, $value, $key->path); 770 $query->finish; 771 772 # if we affected more then one row something very bad has happened. 773 if ($flags eq 'create') { 774 unless ($rows == 1) { 775 $log->logdie( "affected row count is $rows instead of 1" ); 776 } 777 } else { 778 # replace_object_xattr can effect either 1 or 2 rows. 2 rows in 779 # the case of a replace and 1 if the xattr didn't already exist. 780 unless ($rows == 1 or $rows == 2) { 781 $log->logdie( "affected row count is $rows instead of 2" ); 782 } 783 } 784 785 $db->commit; 786 $log->debug("commit"); 787 }; 788 if ($@) { 789 $db->rollback; 790 $log->debug("rollback"); 791 $log->logdie("database error: $@"); 800 TRANS: while (1) { 801 eval { 802 my $query; 803 804 if ($flags eq 'create') { 805 $query = $db->prepare_cached( $sql->new_object_xattr ); 806 } else { 807 # replace 808 $query = $db->prepare_cached( $sql->replace_object_xattr ); 809 } 810 811 # name, value, ext_id 812 my $rows = $query->execute($name, $value, $key->path); 813 $query->finish; 814 815 # if we affected more then one row something very bad has happened. 816 if ($flags eq 'create') { 817 unless ($rows == 1) { 818 $log->logdie( "affected row count is $rows instead of 1" ); 819 } 820 } else { 821 # replace_object_xattr can effect either 1 or 2 rows. 2 rows in 822 # the case of a replace and 1 if the xattr didn't already exist. 823 unless ($rows == 1 or $rows == 2) { 824 $log->logdie( "affected row count is $rows instead of 2" ); 825 } 826 } 827 828 $db->commit; 829 $log->debug("commit"); 830 }; 831 if ($@) { 832 $db->rollback; 833 $log->debug("rollback"); 834 if ($@ =~ /Deadlock found/) { 835 $log->warn("database deadlock retrying transaction: $@"); 836 redo TRANS; 837 } 838 $log->logdie("database error: $@"); 839 } 840 last; 792 841 } 793 842 … … 919 968 $key = parse_neb_key($key); 920 969 921 eval { 922 my $query = $db->prepare_cached( $sql->remove_object_xattr ); 923 # ext_id, name 924 my $rows = $query->execute($key->path, $name); 925 $query->finish; 926 927 # if we affected more then one row something very bad has happened. 928 unless ($rows == 1) { 929 $log->logdie( "affected row count is $rows instead of 1" ); 930 } 931 932 $db->commit; 933 $log->debug("commit"); 934 }; 935 if ($@) { 936 $db->rollback; 937 $log->debug("rollback"); 938 $log->logdie("database error: $@"); 939 } 970 TRANS: while (1) { 971 eval { 972 my $query = $db->prepare_cached( $sql->remove_object_xattr ); 973 # ext_id, name 974 my $rows = $query->execute($key->path, $name); 975 $query->finish; 976 977 # if we affected more then one row something very bad has happened. 978 unless ($rows == 1) { 979 $log->logdie( "affected row count is $rows instead of 1" ); 980 } 981 982 $db->commit; 983 $log->debug("commit"); 984 }; 985 if ($@) { 986 $db->rollback; 987 $log->debug("rollback"); 988 if ($@ =~ /Deadlock found/) { 989 $log->warn("database deadlock retrying transaction: $@"); 990 redo TRANS; 991 } 992 $log->logdie("database error: $@"); 993 } 994 last; 995 } 940 996 941 997 $log->debug("leaving"); … … 1099 1155 $log->debug( "entered - @_" ); 1100 1156 1101 eval { 1102 my $so_id; 1103 my $instances; 1104 # get so_id 1105 { 1106 my $query = $db->prepare_cached( $sql->get_object_from_uri ); 1107 my $rows = $query->execute( $uri ); 1108 1109 unless ( $rows > 0 ) { 1157 TRANS: while (1) { 1158 eval { 1159 my $so_id; 1160 my $instances; 1161 # get so_id 1162 { 1163 my $query = $db->prepare_cached( $sql->get_object_from_uri ); 1164 my $rows = $query->execute( $uri ); 1165 1166 unless ( $rows > 0 ) { 1167 $query->finish; 1168 $log->logdie( "no instance is associated with uri" ); 1169 } 1170 1171 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 1110 1172 $query->finish; 1111 $log->logdie( "no instance is associated with uri" ); 1112 } 1113 1114 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 1115 $query->finish; 1116 1117 } 1118 1119 { 1120 my $query = $db->prepare_cached( $sql->get_instance_count ); 1121 $query->execute( $so_id ); 1122 1123 $instances = $query->fetchrow_hashref->{ 'count(ins_id)' }; 1124 $query->finish; 1125 } 1126 1127 # remove instance 1128 { 1129 my $query = $db->prepare_cached( $sql->delete_instance ); 1130 my $rows = $query->execute( $uri ); 1131 $query->finish; 1132 1133 # if we affected something other then two rows something very bad 1134 # has happened 1135 unless ( $rows == 1 ) { 1136 $log->logdie( "affected row count is $rows instead of 1" ); 1137 } 1138 } 1139 1140 # if we just deleted the last instance associated with a storage object 1141 # remove it too 1142 if ( $instances == 1 ) { 1143 # we just removed the last instance 1144 my $query = $db->prepare_cached( $sql->delete_object ); 1145 my $rows = $query->execute( $so_id ); 1146 $query->finish; 1147 1148 # TODO: this will have to be changed in order to support hardlinks 1149 unless ( $rows == 1 ) { 1150 $log->logdie( "affected row count is $rows instead of 2" ); 1151 } 1152 } 1153 1154 $db->commit; 1155 $log->debug("commit"); 1156 }; 1157 if ( $@ ) { 1158 $db->rollback; 1159 $log->debug("rollback"); 1160 $log->logdie( "database error: $@" ); 1173 1174 } 1175 1176 { 1177 my $query = $db->prepare_cached( $sql->get_instance_count ); 1178 $query->execute( $so_id ); 1179 1180 $instances = $query->fetchrow_hashref->{ 'count(ins_id)' }; 1181 $query->finish; 1182 } 1183 1184 # remove instance 1185 { 1186 my $query = $db->prepare_cached( $sql->delete_instance ); 1187 my $rows = $query->execute( $uri ); 1188 $query->finish; 1189 1190 # if we affected something other then two rows something very bad 1191 # has happened 1192 unless ( $rows == 1 ) { 1193 $log->logdie( "affected row count is $rows instead of 1" ); 1194 } 1195 } 1196 1197 # if we just deleted the last instance associated with a storage object 1198 # remove it too 1199 if ( $instances == 1 ) { 1200 # we just removed the last instance 1201 my $query = $db->prepare_cached( $sql->delete_object ); 1202 my $rows = $query->execute( $so_id ); 1203 $query->finish; 1204 1205 # TODO: this will have to be changed in order to support hardlinks 1206 unless ( $rows == 1 ) { 1207 $log->logdie( "affected row count is $rows instead of 2" ); 1208 } 1209 } 1210 1211 $db->commit; 1212 $log->debug("commit"); 1213 }; 1214 if ( $@ ) { 1215 $db->rollback; 1216 $log->debug("rollback"); 1217 if ($@ =~ /Deadlock found/) { 1218 $log->warn("database deadlock retrying transaction: $@"); 1219 redo TRANS; 1220 } 1221 $log->logdie( "database error: $@" ); 1222 } 1223 last; 1161 1224 } 1162 1225 -
branches/cnb_branches/cnb_branch_20090301/Nebulous/scripts/stats.pl
r23352 r23594 33 33 my $stat = Statistics::Descriptive::Sparse->new(); 34 34 $stat->add_data(@$duration); 35 printf("%-40s %f\n", "$method: mean duration:", $stat->mean());35 printf("%-40s : %f\n", "$method - mean duration", $stat->mean()); 36 36 } 37 37 { … … 40 40 $stat->add_data(@$times); 41 41 $total_stat->add_data(@$times); 42 printf("%-40s %f\n","$method: calls/s:", $stat->count / ($stat->max - $stat->min));42 printf("%-40s : %f\n","$method - calls/s", $stat->count / ($stat->max - $stat->min)); 43 43 } 44 44 } 45 45 46 print "max : ", $total_stat->max, "\n"; 47 print "min : ", $total_stat->min, "\n"; 48 print "total s : ", ($total_stat->max - $total_stat->min), "\n"; 49 print "count : ", $total_stat->count, "\n"; 50 print "total : calls/s: ", $total_stat->count / ($total_stat->max - $total_stat->min), "\n"; 46 print "\n"; 47 printf("%-40s : %f\n", "first timestamp", $total_stat->min); 48 printf("%-40s : %f\n", "last timestamp", $total_stat->max); 49 printf("%-40s : %f\n", "total wallclock seconds", ($total_stat->max - $total_stat->min)); 50 printf("%-40s : %f\n", "total call count", $total_stat->count); 51 printf("%-40s : %f\n", "total calls/s:", $total_stat->count / ($total_stat->max - $total_stat->min)); -
branches/cnb_branches/cnb_branch_20090301/Ohana
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/libohana/src/IOBufferOps.c
r17483 r23594 27 27 int ReadtoIOBuffer (IOBuffer *buffer, int fd) { 28 28 29 int Nread, Nfree ;29 int Nread, Nfree, Nwant; 30 30 31 31 if (fd == 0) { … … 34 34 } 35 35 36 // if we run out of space, double Nblock 36 37 Nfree = buffer[0].Nalloc - buffer[0].Nbuffer; 37 38 if (Nfree < buffer[0].Nblock) { … … 44 45 } 45 46 46 Nread = read (fd, &buffer[0].buffer[buffer[0].Nbuffer], buffer[0].Nblock); 47 if (DEBUG) fprintf (stderr, "read IO buffer: (%lx) %d from %d\n", (unsigned long) buffer, Nread, buffer[0].Nblock); 47 // ensure we never read more than space available 48 Nwant = MIN (Nfree, buffer[0].Nblock); 49 Nread = read (fd, &buffer[0].buffer[buffer[0].Nbuffer], Nwant); 50 if (DEBUG) fprintf (stderr, "read IO buffer: (%lx) %d from %d\n", (unsigned long) buffer, Nread, Nwant); 48 51 49 52 /* on success, increase the block size for the next read */ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/cmd.basic/break.c
r7917 r23594 8 8 remove_argument (N, &argc, argv); 9 9 value = -1; 10 if (!strcasecmp (argv[N], "on")) value = TRUE;11 if (!strcasecmp (argv[N], "off")) value = FALSE;10 if (!strcasecmp (argv[N], "on")) value = 1; 11 if (!strcasecmp (argv[N], "off")) value = 0; 12 12 if (value == -1) { 13 13 gprint (GP_ERR, "USAGE: break -auto [on / off]\n"); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/cmd.basic/run_if.c
r16462 r23594 113 113 status = multicommand (input); 114 114 if (ThisList == 0) add_history (input); 115 if (auto_break && !status) return (FALSE); 115 if (auto_break && !status) { 116 free (input); 117 return (FALSE); 118 } 116 119 } 117 120 } -
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 merged: 23530
- 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 merged: 23530
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/include/pantasks.h
r21153 r23594 244 244 int CheckControllerOutput (void); 245 245 int PrintControllerOutput (void); 246 void PrintControllerBusyJobs (); 246 247 247 248 int AddHost (char *hostname, int max_threads); … … 260 261 261 262 // functions related to the server threads 263 void *CheckJobsAndTasksThread (void *data); 264 262 265 void CheckTasksSetState (int state); 263 266 int CheckTasksGetState (void); 264 void *CheckTasksThread (void *data);265 267 266 268 void CheckJobsSetState (int state); 267 269 int CheckJobsGetState (void); 268 void *CheckJobsThread (void *data); 270 271 // void *CheckTasksThread (void *data); 272 // void *CheckJobsThread (void *data); 269 273 270 274 void CheckControllerSetState (int state); … … 283 287 void CheckInputs (void); 284 288 285 void SerialThreadLock (void); 286 void SerialThreadUnlock (void); 289 void ClientThreadLock (void); 290 void ClientThreadUnlock (void); 291 void CommandThreadLock (void); 292 void CommandThreadUnlock (void); 293 void ControlThreadLock (void); 294 void ControlThreadUnlock (void); 295 void JobTaskThreadLock (void); 296 void JobTaskThreadUnlock (void); 287 297 288 298 int InitPassword (void); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/include/shell.h
r21153 r23594 166 166 int gprint PROTO((gpDest dest, char *format, ...)); 167 167 int gwrite PROTO((char *buffer, int size, int N, gpDest dest)); 168 int gprint_syserror PROTO((gpDest dest, int myError, char *format, ...)); 169 int gprintv PROTO((gpDest dest, char *format, va_list argp)); 168 170 169 171 /* socket functions */ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/lib.shell/SocketOps.c
r21041 r23594 5 5 # define DEBUG 0 6 6 7 // these three static variables are only modified in the setup command before 8 // the threads are started. Thread-safety is not a problem for these. 7 9 static int NVALID; 8 10 static int Nvalid; -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/lib.shell/gprint.c
r22423 r23594 287 287 288 288 int status; 289 gpStream *stream;290 289 va_list argp; 291 290 291 va_start (argp, format); 292 status = gprintv (dest, format, argp); 293 va_end (argp); 294 return (status); 295 } 296 297 int gprintv (gpDest dest, char *format, va_list argp) { 298 299 int status; 300 gpStream *stream; 301 292 302 // this thread only writes to its own stream 293 303 stream = gprintGetStream (dest); 294 295 va_start (argp, format);296 304 297 305 if (stream[0].mode == GP_FILE) { … … 303 311 vPrintIOBuffer (stream[0].buffer, format, argp); 304 312 } 305 va_end (argp);306 313 return (TRUE); 307 314 } … … 332 339 } 333 340 334 /* I'm going to need to have different output targets for different threads 335 we can do this with these functions: 336 337 pthread_t pthread_self(void); 338 int pthread_equal(pthread_t thread1, pthread_t thread2); 339 // returns TRUE if equal, FALSE if not 340 341 */ 342 341 # define MAX_ERROR_LENGTH 256 // Maximum length string for error messages 342 343 // print an error (based on errno values) to gprint destination 344 int gprint_syserror (gpDest dest, int myError, char *format, ...) { 345 346 char errorBuf[MAX_ERROR_LENGTH]; 347 char *errorMsg; 348 va_list argp; 349 350 // there are two strerror_r implementations; choose the right one: 351 #if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) 352 errorMsg = strerror_r (myError, errorBuf, MAX_ERROR_LENGTH); 353 #else 354 strerror_r (myError, errorBuf, MAX_ERROR_LENGTH); 355 errorMsg = errorBuf; 356 #endif 357 358 va_start (argp, format); 359 gprintv (dest, format, argp); 360 va_end (argp); 361 362 gprintv (dest, "%s\n", errorMsg); 363 return TRUE; 364 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/CheckController.c
r14590 r23594 1 1 # include "pantasks.h" 2 2 3 static struct timeval start; 4 void TimerMark (); 5 float TimerElapsed (int reset); 3 void TimerMark (struct timeval *start); 4 float TimerElapsed (struct timeval *start, int reset); 6 5 7 6 int CheckController () { … … 11 10 Job *job; 12 11 IOBuffer buffer; 12 struct timeval start; 13 13 14 14 /* get the list of completed jobs (exit / crash), update the job status */ … … 17 17 /*** check EXIT jobs ***/ 18 18 InitIOBuffer (&buffer, 0x100); 19 // TimerMark ();20 // status = ControllerCommand ("stop", CONTROLLER_PROMPT, &buffer);21 // if (VerboseMode()) gprint (GP_ERR, "stop controller %f\n", TimerElapsed(TRUE));22 19 23 TimerMark ( );20 TimerMark (&start); 24 21 FlushIOBuffer (&buffer); 22 25 23 status = ControllerCommand ("jobstack exit", CONTROLLER_PROMPT, &buffer); 26 if (VerboseMode()) gprint (GP_ERR, "check exit stack %f\n", TimerElapsed( TRUE));24 if (VerboseMode()) gprint (GP_ERR, "check exit stack %f\n", TimerElapsed(&start, TRUE)); 27 25 if (!status) goto escape; 28 26 … … 34 32 status = sscanf (buffer.buffer, "%*s %d", &Njobs); 35 33 if (status != 1) goto escape; 36 if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed( TRUE));34 if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(&start, TRUE)); 37 35 38 36 p = buffer.buffer; … … 46 44 status = sscanf (p, "%d", &JobID); 47 45 46 // the operations within this locked block only interact with the controller or 47 // modify the properties of the selected job 48 JobTaskLock(); 48 49 job = FindControllerJob (JobID); 49 50 if (job == NULL) { 50 51 gprint (GP_ERR, "misplaced job? %d not in EXIT job list\n", JobID); 52 JobTaskUnlock(); 51 53 continue; 52 54 } 53 55 /* this checks the individual job status, grabs stdout/stderr */ 54 56 CheckControllerJob (job); 57 JobTaskUnlock(); 55 58 } 56 if (VerboseMode()) gprint (GP_ERR, "clear %d exit jobs %f\n", i, TimerElapsed( TRUE));59 if (VerboseMode()) gprint (GP_ERR, "clear %d exit jobs %f\n", i, TimerElapsed(&start, TRUE)); 57 60 58 61 /*** check CRASH jobs ***/ … … 67 70 status = sscanf (buffer.buffer, "%*s %d", &Njobs); 68 71 if (status != 1) goto escape; 69 if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed( TRUE));72 if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(&start, TRUE)); 70 73 71 74 p = buffer.buffer; … … 77 80 } 78 81 p = q + 1; 79 80 82 status = sscanf (p, "%d", &JobID); 83 84 // the operations within this locked block only interact with the controller or 85 // modify the properties of the selected job 86 JobTaskLock(); 81 87 job = FindControllerJob (JobID); 82 88 if (job == NULL) { 83 89 gprint (GP_ERR, "misplaced job? %d not in CRASH job list\n", JobID); 90 JobTaskUnlock(); 84 91 continue; 85 92 } 86 93 /* this checks the individual job status, grabs stdout/stderr */ 87 94 CheckControllerJob (job); 95 JobTaskUnlock(); 88 96 } 89 if (VerboseMode()) gprint (GP_ERR, "clear %d crash jobs %f\n", i, TimerElapsed( TRUE));97 if (VerboseMode()) gprint (GP_ERR, "clear %d crash jobs %f\n", i, TimerElapsed(&start, TRUE)); 90 98 91 99 FlushIOBuffer (&buffer); 92 // status = ControllerCommand ("run", CONTROLLER_PROMPT, &buffer);93 100 FreeIOBuffer (&buffer); 94 101 return (TRUE); … … 96 103 escape: 97 104 FlushIOBuffer (&buffer); 98 // status = ControllerCommand ("run", CONTROLLER_PROMPT, &buffer);99 105 FreeIOBuffer (&buffer); 100 106 return (FALSE); 101 107 } 102 108 103 void TimerMark ( ) {104 gettimeofday ( &start, (void *) NULL);109 void TimerMark (struct timeval *start) { 110 gettimeofday (start, (void *) NULL); 105 111 } 106 112 107 float TimerElapsed ( int reset) {113 float TimerElapsed (struct timeval *start, int reset) { 108 114 109 115 float dtime; … … 111 117 112 118 gettimeofday (&stop, (void *) NULL); 113 dtime = DTIME (stop, start );114 if (reset) gettimeofday ( &start, (void *) NULL);119 dtime = DTIME (stop, start[0]); 120 if (reset) gettimeofday (start, (void *) NULL); 115 121 return (dtime); 116 122 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/CheckJobs.c
r15871 r23594 18 18 next_timeout = 1.0; 19 19 20 JobTaskLock(); 20 21 /** test all jobs: ready to test? finished? **/ 21 22 while ((job = NextJob ()) != NULL) { … … 77 78 /* set taskarg variables */ 78 79 for (i = 0; i < job[0].argc; i++) { 79 sprintf (varname, "taskarg:%d", i);80 set_str_variable (varname, job[0].argv[i]);80 sprintf (varname, "taskarg:%d", i); 81 set_str_variable (varname, job[0].argv[i]); 81 82 } 82 83 set_int_variable ("taskarg:n", job[0].argc); … … 84 85 /* set options variables */ 85 86 for (i = 0; i < job[0].optc; i++) { 86 sprintf (varname, "options:%d", i);87 set_str_variable (varname, job[0].optv[i]);87 sprintf (varname, "options:%d", i); 88 set_str_variable (varname, job[0].optv[i]); 88 89 } 89 90 set_int_variable ("options:n", job[0].optc); … … 109 110 if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", task[0].name, job[0].JobID); 110 111 if (task[0].crash != NULL) { 112 // we need to unlock JobTask since JobTaskLock is called inside CommandLock in the client thread 113 JobTaskUnlock(); 114 CommandLock(); 111 115 exec_loop (task[0].crash); 116 CommandUnlock(); 117 JobTaskLock(); 112 118 } 113 119 } … … 133 139 } 134 140 } 135 if (macro != NULL) exec_loop (macro); 141 if (macro != NULL) { 142 // we need to unlock JobTask since JobTaskLock is called inside CommandLock in the client thread 143 JobTaskUnlock(); 144 CommandLock(); 145 exec_loop (macro); 146 CommandUnlock(); 147 JobTaskLock(); 148 } 136 149 } 137 150 … … 146 159 DeleteJob (job); 147 160 continue; 148 break;149 161 150 162 default: … … 156 168 /* check for timeout - (local jobs only) 157 169 we only check timeout after a poll (forces at least one poll) 158 */170 */ 159 171 if (job[0].mode == JOB_LOCAL) { 160 172 if (GetTaskTimer(job[0].start, FALSE) < task[0].timeout_period) { … … 179 191 /* set taskarg variables */ 180 192 for (i = 0; i < job[0].argc; i++) { 181 sprintf (varname, "taskarg:%d", i);182 set_str_variable (varname, job[0].argv[i]);193 sprintf (varname, "taskarg:%d", i); 194 set_str_variable (varname, job[0].argv[i]); 183 195 } 184 196 set_int_variable ("taskarg:n", job[0].argc); … … 193 205 /* run task[0].timeout macro, if it exists */ 194 206 if (task[0].timeout != NULL) { 207 // we need to unlock JobTask since JobTaskLock is called inside CommandLock in the client thread 208 JobTaskUnlock(); 209 CommandLock(); 195 210 exec_loop (task[0].timeout); 211 CommandUnlock(); 212 JobTaskLock(); 196 213 } 197 214 … … 205 222 } 206 223 // fprintf (stderr, "check %d jobs\n", Ncheck); 224 JobTaskUnlock(); 207 225 return (next_timeout); 208 226 } … … 210 228 /* 211 229 212 job / task timeline:213 214 task:215 0 exec216 start create217 task clock new job218 219 job:220 0 1xpoll 2xpoll 3xpoll221 start check check check222 job clock status status status223 224 . . . timeout225 run226 timeout227 228 must be at least one poll before timeout229 (timeout >= poll)230 job / task timeline: 231 232 task: 233 0 exec 234 start create 235 task clock new job 236 237 job: 238 0 1xpoll 2xpoll 3xpoll 239 start check check check 240 job clock status status status 241 242 . . . timeout 243 run 244 timeout 245 246 must be at least one poll before timeout 247 (timeout >= poll) 230 248 */ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/CheckPassword.c
r8548 r23594 2 2 # define DEBUG 0 3 3 4 // this static var is only used by InitPassword and CheckPassword below. 5 // Both functions are only called by the main thread. 4 6 static char PASSWORD[256]; 5 7 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/CheckTasks.c
r23352 r23594 7 7 int status; 8 8 float time_running, next_timeout, fuzz; 9 // struct timeval now;10 9 11 10 // actual maximum delay is controlled in job_threads.c 12 11 next_timeout = 1.0; 13 12 13 JobTaskLock(); 14 14 /** test all tasks: ready to test? ready to run? **/ 15 15 while ((task = NextTask ()) != NULL) { … … 48 48 // add random offset between 0 and 5% of exec_period 49 49 // XXX this should be optional 50 fuzz = 0.1*task[0].exec_period*drand48();50 fuzz = task[0].exec_period*(0.5*drand48() - 0.25); 51 51 task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz); 52 52 task[0].last.tv_sec += (int) fuzz; … … 54 54 /* ready to run? : run task.exec macro */ 55 55 if (task[0].exec != NULL) { 56 // we need to unlock JobTask since JobTaskLock is called inside CommandLock in the client thread 57 JobTaskUnlock(); 58 CommandLock(); 56 59 status = exec_loop (task[0].exec); 60 CommandUnlock(); 61 JobTaskLock(); 57 62 if (!status) { 58 63 continue; 59 64 } 60 65 } 61 62 // gettimeofday (&now, (void *) NULL);63 // fprintf (stderr, "t1: %d %6d - \n", now.tv_sec, now.tv_usec);64 66 65 67 /* check if there are errors with this task */ … … 68 70 } 69 71 70 // gettimeofday (&now, (void *) NULL);71 // fprintf (stderr, "t2: %d %6d - \n", now.tv_sec, now.tv_usec);72 73 72 /* construct job from task */ 74 73 job = CreateJob (task); 74 if (!job) { 75 continue; 76 } 77 75 78 if (DEBUG) fprintf (stderr, "create job: (%zx) %d of %d\n", (size_t) job[0].stdout_buff.buffer, job[0].stdout_buff.Nbuffer, job[0].stdout_buff.Nalloc); 76 79 77 // gettimeofday (&now, (void *) NULL); 78 // fprintf (stderr, "t3: %d %6d - \n", now.tv_sec, now.tv_usec); 79 80 /* execute job - XXX add status test */ 81 SubmitJob (job); 82 83 // fprintf (stderr, "nl: %d %6d - ", 84 // task[0].last.tv_sec, task[0].last.tv_usec); 85 86 /* increment job counters */ 87 task[0].Njobs ++; 88 task[0].Npending ++; 89 90 // fprintf (stderr, "%d %6d\n", 91 // task[0].last.tv_sec, task[0].last.tv_usec); 80 /* execute job */ 81 if (!SubmitJob (job)) { 82 DeleteJob (job); 83 continue; 84 } 85 task[0].Njobs ++; // number of jobs successfully submitted 92 86 93 87 /* increment Nrun for inclusive ranges with Nmax */ 94 88 BumpTimeRanges (task[0].ranges, task[0].Nranges); 95 89 } 90 JobTaskUnlock(); 96 91 return (next_timeout); 97 92 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/ControllerOps.c
r20032 r23594 12 12 13 13 /* local static variables to track the controller host properties */ 14 /* these are used by AddHost and DeleteHost, and are only called by controller_host.c (clientThread) */ 15 /* or by RestartController : lock between these two? */ 14 16 static Host *hosts = NULL; 15 17 static int Nhosts = 0; … … 31 33 } 32 34 35 // XXX possible race condition problem: if we delete a host while the controller 36 // is being restarted. to fix this, we need to keep the deletion in controller_thread, 37 // but perhaps mark it in the client_thread? 33 38 int DeleteHost (char *hostname) { 34 39 … … 261 266 } 262 267 268 // This function is called by the JobTaskThread via SubmitJob. We need to unlock the 269 // JobTaskLock to avoid a dead lock with the JobTaskLock called in CheckController 270 JobTaskUnlock(); 271 ControlLock(__func__); 263 272 InitIOBuffer (&buffer, 0x100); 264 273 status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer); 265 274 free (cmd); 275 ControlUnlock(__func__); 276 JobTaskLock(); 277 266 278 267 279 /* extract the job PID from the controller response */ … … 274 286 } 275 287 sscanf (p, "%*s %s", string); 288 FreeIOBuffer (&buffer); 289 276 290 job[0].pid = atoi (string); 277 FreeIOBuffer (&buffer); 291 if (job[0].pid < 0) { 292 return (FALSE); 293 } 278 294 return (TRUE); 279 295 } … … 411 427 if ((status == -1) && (errno == EPIPE)) { 412 428 StopController (); 413 gprint (GP_ERR, "controller is down (pipe closed), restarting\n");429 fprintf (stderr, "controller is down (pipe closed), restarting\n"); 414 430 if (!RestartController ()) { 415 431 return (FALSE); … … 434 450 if (status == 0) { 435 451 StopController (); 436 gprint (GP_ERR, "controller is down (EOF), restarting\n");452 fprintf (stderr, "controller is down (EOF), restarting\n"); 437 453 if (!RestartController ()) { 438 454 return (FALSE); … … 441 457 } 442 458 if (status == -1) { 443 gprint (GP_ERR, "controller is not responding (%d tries)\n", j);459 fprintf (stderr, "controller is not responding (%d tries)\n", j); 444 460 gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR); 445 461 } 446 462 } 447 463 if (status == -1) { 448 gprint (GP_ERR, "controller still not responding, giving up\n");464 fprintf (stderr, "controller still not responding, giving up\n"); 449 465 return (FALSE); 450 466 } … … 456 472 bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer); 457 473 } 458 /* if (VerboseMode()) gprint (GP_ERR, "message received, %d cycles\n", i); */474 if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i); 459 475 return (TRUE); 460 476 } … … 492 508 } 493 509 510 void PrintControllerBusyJobs () { 511 512 int status; 513 char command[1024]; 514 IOBuffer buffer; 515 516 /* check if controller is running */ 517 status = CheckControllerStatus (); 518 if (!status) { 519 return; 520 } 521 522 sprintf (command, "jobstack busy"); 523 InitIOBuffer (&buffer, 0x100); 524 525 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 526 527 if (status) { 528 gprint (GP_LOG, " jobs currently running remotely:\n"); 529 gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); 530 } else { 531 gprint (GP_LOG, "controller is not responding\n"); 532 } 533 FreeIOBuffer (&buffer); 534 return; 535 } 536 494 537 int PrintControllerOutput () { 495 538 … … 581 624 InitIOBuffer (&buffer, 0x100); 582 625 583 // XXX lock the host table? SerialThreadLock ();626 // XXX lock the host table? no: that would risk a dead lock between client and controller threads: 584 627 gprint (GP_ERR, "pcontrol restarted, reloading hosts\n"); 585 628 for (i = 0; i < Nhosts; i++) { … … 588 631 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 589 632 } 590 // SerialThreadUnlock ();591 633 592 634 if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/InputQueue.c
r16449 r23594 1 1 # include "pantasks.h" 2 // we use fprintf for DEBUG statements to avoid deadlocking issues 2 3 3 4 static int Ninputs = 0; … … 23 24 void AddNewInput (char *input) { 24 25 26 // XXX define the InputMutex 25 27 SerialThreadLock (); 26 if (DEBUG) gprint (GP_LOG, "adding a new input (%s)\n", input); 28 29 if (DEBUG) fprintf (stderr, "adding a new input (%s)\n", input); 27 30 inputs[Ninputs] = input; 28 31 Ninputs ++; … … 31 34 REALLOCATE (inputs, char *, NINPUTS); 32 35 } 33 if (DEBUG) gprint (GP_LOG, "done new input (%s)\n", input);36 if (DEBUG) fprintf (stderr, "done new input (%s)\n", input); 34 37 SerialThreadUnlock (); 35 38 } … … 40 43 int i, j; 41 44 42 if (DEBUG) gprint (GP_LOG, "deleting an input (%s)\n", input); 45 if (DEBUG) fprintf (stderr, "deleting an input (%s)\n", input); 46 47 // XXX lock here 43 48 for (i = 0; i < Ninputs; i++) { 44 49 if (inputs[i] == input) { … … 52 57 REALLOCATE (inputs, char *, NINPUTS); 53 58 } 54 if (DEBUG) gprint (GP_LOG, "deleted an input\n"); 59 // XXX unlock here 60 if (DEBUG) fprintf (stderr, "deleted an input\n"); 55 61 return TRUE; 56 62 } 57 63 } 58 64 // did not find the input 65 // XXX unlock here 59 66 return FALSE; 60 67 } … … 66 73 char *input, *line, *outline, tmp; 67 74 68 if (Ninputs < 1) return; 75 // XXX lock here 76 if (Ninputs < 1) { 77 // XXX unlock here 78 return; 79 } 69 80 70 81 input = inputs[0]; 71 if (DEBUG) gprint (GP_LOG, "got an input (%s)\n", input);82 if (DEBUG) fprintf (stderr, "got an input (%s)\n", input); 72 83 73 84 Nbytes = snprintf (&tmp, 0, "input %s", input); 74 85 ALLOCATE (line, char, Nbytes + 1); 75 86 snprintf (line, Nbytes + 1, "input %s", input); 87 // XXX unlock here 76 88 77 89 status = command (line, &outline, TRUE); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/JobIDOps.c
r17419 r23594 1 1 # include "pantasks.h" 2 2 3 # define MAX_N_JOBS 1000 3 # define MAX_N_JOBS 10000 4 4 static char *JobIDList; 5 5 static int JobIDPtr; -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/JobOps.c
r18160 r23594 88 88 } 89 89 90 /* check if controller is running */91 status = CheckControllerStatus ();92 if (!status) {93 return;94 }95 96 sprintf (command, "jobstack busy");97 InitIOBuffer (&buffer, 0x100);98 99 SerialThreadLock ();100 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);101 SerialThreadUnlock ();102 103 if (status) {104 gprint (GP_LOG, " jobs currently running remotely:\n");105 gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);106 } else {107 gprint (GP_LOG, "controller is not responding\n");108 }109 FreeIOBuffer (&buffer);110 90 return; 111 91 } … … 120 100 121 101 job[0].JobID = NextJobID (); 102 if (job[0].JobID < 0) { 103 free (job); 104 return NULL; 105 } 106 122 107 job[0].pid = 0; 123 108 job[0].mode = JOB_LOCAL; … … 169 154 REALLOCATE (jobs, Job *, NJOBS); 170 155 } 156 157 /* increment job counters */ 158 task[0].Npending ++; 159 171 160 return (jobs[Njobs-1]); 172 161 } … … 265 254 int SubmitJob (Job *job) { 266 255 256 int status; 257 267 258 if (job[0].mode == JOB_LOCAL) { 268 259 if (DEBUG) fprintf (stderr, "submit job: (%zx) %d of %d\n", (size_t) job[0].stdout_buff.buffer, job[0].stdout_buff.Nbuffer, job[0].stdout_buff.Nalloc); 269 SubmitLocalJob (job);260 status = SubmitLocalJob (job); 270 261 } else { 271 SubmitControllerJob (job); 262 status = SubmitControllerJob (job); 263 } 264 if (!status) { 265 return FALSE; 272 266 } 273 267 … … 285 279 if (job[0].mode == JOB_LOCAL) { 286 280 CheckLocalJob (job); 287 } else { 288 /* controller jobs are now checked en masse by CheckController */ 289 /* CheckControllerJob (job); */ 281 /* controller jobs are checked en masse by CheckController */ 290 282 } 291 283 return (job[0].state); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/ListenClients.c
r16905 r23594 2 2 # define DEBUG 0 3 3 4 // XXX make the calling functions thread-safe 4 5 static int NCLIENTS; 5 6 static int Nclients; … … 9 10 void InitClients () { 10 11 12 ClientLock(); 11 13 Nclients = 0; 12 14 NCLIENTS = 10; 13 15 ALLOCATE (clients, int, NCLIENTS); 14 16 ALLOCATE (buffers, IOBuffer *, NCLIENTS); 17 ClientUnlock(); 15 18 } 16 19 … … 18 21 void AddNewClient (int client) { 19 22 20 if (DEBUG) gprint (GP_LOG, "adding a new client (%d)\n", client); 23 ClientLock(); 24 if (DEBUG) fprintf (stderr, "adding a new client (%d)\n", client); 21 25 clients[Nclients] = client; 22 26 ALLOCATE (buffers[Nclients], IOBuffer, 1); … … 28 32 REALLOCATE (buffers, IOBuffer *, NCLIENTS); 29 33 } 34 ClientUnlock(); 30 35 } 31 36 … … 35 40 int i, j; 36 41 37 if (DEBUG) gprint (GP_LOG, "deleting a client (%d)\n", client); 42 ClientLock(); 43 if (DEBUG) fprintf (stderr, "deleting a client (%d)\n", client); 38 44 for (i = 0; i < Nclients; i++) { 39 45 if (clients[i] == client) { … … 51 57 REALLOCATE (buffers, IOBuffer *, NCLIENTS); 52 58 } 59 ClientUnlock(); 53 60 return TRUE; 54 61 } 55 62 } 56 63 // did not find the client 64 ClientUnlock(); 57 65 return FALSE; 58 66 } … … 70 78 gprintInit (); // each thread needs to init the printing system 71 79 72 // define server output log files 73 if (VarConfig ("PANTASKS_SERVER_STDOUT", "%s", log_stdout) != NULL) { 74 gprintSetFileThisThread (GP_LOG, log_stdout); 75 } else { 76 strcpy (log_stdout, "stdout"); 77 } 78 if (VarConfig ("PANTASKS_SERVER_STDERR", "%s", log_stderr) != NULL) { 79 gprintSetFileThisThread (GP_ERR, log_stderr); 80 } else { 81 strcpy (log_stderr, "stderr"); 82 } 80 /* set buffers for the output for this client */ 81 gprintSetBuffer (GP_LOG); 82 gprintSetBuffer (GP_ERR); 83 83 84 84 while (1) { … … 90 90 91 91 /* place all of the clients in the fdSet */ 92 Ncurrent = Nclients;93 92 Nmax = 0; 94 93 FD_ZERO (&fdSet); 94 ClientLock(); 95 Ncurrent = Nclients; 96 ClientUnlock(); 95 97 for (i = 0; i < Ncurrent; i++) { 96 98 Nmax = MAX (Nmax, clients[i]); … … 100 102 101 103 /* block until we have some data on the pipes (or timeout) */ 102 if (DEBUG) gprint (GP_ERR, "listening to %d clients\n", Ncurrent);104 if (DEBUG) fprintf (stderr, "listening to %d clients\n", Ncurrent); 103 105 status = select (Nmax, &fdSet, NULL, NULL, &timeout); 104 106 if (status == -1) { … … 122 124 if ((Nread == 0) || (Nread == -2)) { 123 125 /* error: do something */ 124 if (DEBUG && (Nread == 0)) gprint (GP_ERR, "socket is closed\n");125 if (DEBUG && (Nread == -2)) gprint (GP_ERR, "error reading from socket\n");126 if (DEBUG && (Nread == 0)) fprintf (stderr, "socket is closed\n"); 127 if (DEBUG && (Nread == -2)) fprintf (stderr, "error reading from socket\n"); 126 128 DeleteClient (clients[i]); 127 continue;129 break; // the other thread could also have modified the list; restart with new Ncurrent 128 130 } 129 131 130 if (DEBUG) gprint (GP_ERR, "read %d total bytes\n", buffers[i][0].Nbuffer);132 if (DEBUG) fprintf (stderr, "read %d total bytes\n", buffers[i][0].Nbuffer); 131 133 132 134 /* see if we have a complete message waiting; if not, keep waiting for messages */ … … 141 143 if (*line) { 142 144 143 /* set buffers for the output for this client */144 gprintSetBuffer (GP_LOG);145 gprintSetBuffer (GP_ERR);146 147 145 /* run the command, return the exit status */ 146 CommandLock(); 148 147 status = multicommand (line); 148 CommandUnlock(); 149 149 SendMessage (clients[i], "STATUS %d", status); 150 150 … … 156 156 SendMessageFixed (clients[i], 0, ""); 157 157 } 158 FlushIOBuffer (outbuffer); 158 159 159 160 // return the stdout messages first … … 164 165 SendMessageFixed (clients[i], 0, ""); 165 166 } 166 167 /* clear and reset the output buffers to their last output file names */ 168 gprintSetFileAllThreads (GP_LOG, NULL); 169 gprintSetFileAllThreads (GP_ERR, NULL); 167 FlushIOBuffer (outbuffer); 170 168 } 171 169 free (line); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/LocalJob.c
r18161 r23594 127 127 128 128 pid = fork (); 129 if (pid == -1) { 130 gprint_syserror (GP_ERR, errno, "error starting local job: "); 131 goto pipe_error; 132 } 133 129 134 if (!pid) { /* must be child process */ 130 135 if (VerboseMode()) gprint (GP_ERR, "starting local job\n"); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/Makefile
r18085 r23594 34 34 $(SRC)/pantasks.$(ARCH).o \ 35 35 $(SRC)/thread_locks.$(ARCH).o \ 36 $(SRC)/job_threads.$(ARCH).o \ 37 $(SRC)/task_threads.$(ARCH).o \ 36 $(SRC)/jobs_and_tasks_thread.$(ARCH).o \ 38 37 $(SRC)/controller_threads.$(ARCH).o 39 38 … … 41 40 $(SRC)/pantasks_server.$(ARCH).o \ 42 41 $(SRC)/server_run.$(ARCH).o \ 43 $(SRC)/server_load.$(ARCH).o \44 $(SRC)/InputQueue.$(ARCH).o \45 42 $(SRC)/ListenClients.$(ARCH).o \ 46 43 $(SRC)/server.$(ARCH).o \ … … 49 46 $(SRC)/CheckPassword.$(ARCH).o \ 50 47 $(SRC)/thread_locks.$(ARCH).o \ 51 $(SRC)/job_threads.$(ARCH).o \ 52 $(SRC)/task_threads.$(ARCH).o \ 53 $(SRC)/controller_threads.$(ARCH).o \ 54 $(SRC)/input_threads.$(ARCH).o 48 $(SRC)/jobs_and_tasks_thread.$(ARCH).o \ 49 $(SRC)/controller_threads.$(ARCH).o 55 50 56 51 funcs = \ … … 66 61 67 62 cmds = \ 68 $(SRC)/pulse.$(ARCH).o \69 63 $(SRC)/status.$(ARCH).o \ 70 64 $(SRC)/flush.$(ARCH).o \ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller.c
r18085 r23594 50 50 } 51 51 52 ControlLock(__func__); 52 53 status = (*func)(argc - 1, argv + 1); 54 ControlUnlock(__func__); 53 55 return (status); 54 56 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller_host.c
r19125 r23594 15 15 16 16 if (argc != 3) goto usage; 17 if (max_threads && strcasecmp (argv[1], "ADD")) goto usage; 17 18 18 19 /* start controller connection (if needed) */ … … 27 28 if (!strcasecmp (argv[1], "ADD")) { 28 29 AddHost (argv[2], max_threads); 29 } else { 30 if (max_threads) goto usage; 31 } 30 } 32 31 33 32 if (!strcasecmp (argv[1], "DELETE")) { … … 42 41 InitIOBuffer (&buffer, 0x100); 43 42 44 SerialThreadLock ();45 43 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 46 SerialThreadUnlock ();47 44 48 45 if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG); … … 57 54 return (FALSE); 58 55 } 59 60 /* should I keep an internal host table so I can reload the61 hosts if the controller exits?62 63 alternatively, that could be a user-level choice64 */ -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller_jobstack.c
r18085 r23594 24 24 InitIOBuffer (&buffer, 0x100); 25 25 26 SerialThreadLock ();27 26 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 28 SerialThreadUnlock ();29 27 30 28 if (status) { -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller_status.c
r8548 r23594 23 23 InitIOBuffer (&buffer, 0x100); 24 24 25 SerialThreadLock ();26 25 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 27 SerialThreadUnlock ();28 26 29 27 if (status) { -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller_threads.c
r15791 r23594 34 34 35 35 // one run of the task checker 36 SerialThreadLock ();36 ControlLock(__func__); 37 37 CheckController (); 38 ControlUnlock(__func__); 39 40 ControlLock(__func__); 38 41 CheckControllerOutput (); 39 SerialThreadUnlock (); 42 ControlUnlock(__func__); 43 40 44 if (VerboseMode() == 2) fprintf (stderr, "C"); 41 45 // fprintf (stderr, "**** C ****"); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/controller_verbose.c
r18085 r23594 24 24 InitIOBuffer (&buffer, 0x100); 25 25 26 SerialThreadLock ();27 26 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 28 SerialThreadUnlock ();29 27 30 28 if (status) { -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/delete.c
r13542 r23594 11 11 JobID = atoi (argv[2]); 12 12 13 JobTaskLock(); 13 14 job = FindJob (JobID); 14 15 if (job == NULL) { 15 16 gprint (GP_LOG, "job not found\n"); 17 JobTaskUnlock(); 16 18 return (TRUE); 17 19 } … … 21 23 job[0].state = JOB_HUNG; 22 24 if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid); 25 JobTaskUnlock(); 23 26 return (FALSE); 24 27 } … … 27 30 job[0].state = JOB_HUNG; 28 31 if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid); 32 JobTaskUnlock(); 29 33 return (FALSE); 30 34 } … … 32 36 DeleteJob (job); 33 37 gprint (GP_LOG, "job removed\n"); 38 JobTaskUnlock(); 34 39 return (TRUE); 35 40 } … … 41 46 42 47 usage: 43 gprint (GP_ERR, "USAGE: delete job (JobID)\n");44 gprint (GP_ERR, "USAGE: delete task (TaskName)\n");45 return (FALSE);48 gprint (GP_ERR, "USAGE: delete job (JobID)\n"); 49 gprint (GP_ERR, "USAGE: delete task (TaskName)\n"); 50 return (FALSE); 46 51 } 47 52 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/flush.c
r14590 r23594 6 6 7 7 if (!strcasecmp (argv[1], "jobs")) { 8 JobTaskLock(); 8 9 FlushJobs (); 10 JobTaskUnlock(); 9 11 return (TRUE); 10 12 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/init.c
r16453 r23594 18 18 int halt PROTO((int, char **)); 19 19 int flush_jobs PROTO((int, char **)); 20 int pulse PROTO((int, char **));21 20 int showtask PROTO((int, char **)); 22 21 int status_sys PROTO((int, char **)); … … 40 39 {1, "options", task_options, "define optional variables associated with the job task"}, 41 40 {1, "periods", task_periods, "define time scales for a task"}, 42 {1, "pulse", pulse, "set the scheduler update period"},43 41 {1, "run", run, "run the scheduler"}, 44 42 {1, "flush", flush_jobs, "flush all jobs from the queue"}, -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/init_server.c
r16903 r23594 14 14 int task_stdout PROTO((int, char **)); 15 15 int task_stderr PROTO((int, char **)); 16 int pulse PROTO((int, char **));17 16 int flush_jobs PROTO((int, char **)); 18 17 int status_server PROTO((int, char **)); … … 41 40 {1, "npending", task_npending, "define maximum number of outstanding jobs for a task"}, 42 41 {1, "periods", task_periods, "define time scales for a task"}, 43 {1, "pulse", pulse, "set the scheduler update period"},44 42 {1, "flush", flush_jobs, "flush all jobs from the queue"}, 45 43 {1, "server", server, "server-specific commands"}, … … 67 65 InitJobs (); 68 66 InitJobIDs (); 69 InitInputs ();70 67 71 68 for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) { … … 78 75 FreeJobs (); 79 76 FreeJobIDs (); 80 FreeInputs ();81 77 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/kill.c
r13542 r23594 12 12 JobID = atoi (argv[1]); 13 13 14 JobTaskLock(); 14 15 job = FindJob (JobID); 15 16 if (job == NULL) { 16 17 gprint (GP_LOG, "job not found\n"); 18 JobTaskUnlock(); 17 19 return (TRUE); 18 20 } … … 22 24 job[0].state = JOB_HUNG; 23 25 if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid); 26 JobTaskUnlock(); 24 27 return (FALSE); 25 28 } … … 28 31 job[0].state = JOB_HUNG; 29 32 if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid); 33 JobTaskUnlock(); 30 34 return (FALSE); 31 35 } … … 33 37 DeleteJob (job); 34 38 gprint (GP_LOG, "job removed\n"); 39 JobTaskUnlock(); 35 40 return (TRUE); 36 41 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/notes.txt
r7892 r23594 1 2 stdout_cntl: 3 GetJobOutout 4 CheckControllerJob 5 CheckController 6 controller_threads (controlThread) 7 StartController 8 ControllerCommand 9 CheckController 10 controller_threads (controlThread) 11 controller_check (clientThread) 12 controller_host (clientThread) 13 controller_jobstack (clientThread) 14 controller_run (clientThread) 15 controller_status (clientThread) 16 controller_verbose (clientThread) 17 DeleteControllerJob 18 CheckControllerJob 19 CheckController 20 controller_threads (controlThread) 21 CheckControllerJobStatus 22 CheckControllerJob 23 CheckController 24 controller_threads (controlThread) 25 SubmitControllerJob 26 SubmitJob 27 CheckTasks (JobTaskThread) 28 PrintControllerBusyJobs 29 KillControllerJob 30 QuitController 31 RestartController 32 CheckControllerOutput 33 controller_output (clientThread) 34 controller_threads (controlThread) 35 36 37 38 39 40 41 42 20090322 43 44 We've been surviving with a slightly broken threading / locking 45 model. I would like to clean it up. Previously, the threads where 46 blocking at a very coarse level, and there were certain interactions 47 that were not thread-safe. Here are my notes on re-working this: 48 49 * we have 6 threads: 50 51 * main (top-level parent) : after it spawns the 5 child threads, 52 this thread waits for new clients and adds them to the list of 53 active clients with 'AddNewClient' 54 55 * clientsThread (ListenClients): this thread is listening for 56 commands from the clients; when it receives a complete command, 57 it executes the command using 'multicommand'. 58 59 * tasksThread 60 CheckTasks 61 NextTask 62 63 64 65 * jobsThread 66 67 * controllerThread 68 CheckControllerStatus : race condition is irrelevant 69 70 * inputsThread 71 AddNewInput called by clientThread 72 (not sure this is really being used: 73 server input (filename) calls 'input' 74 server module (filename) calls 'module' 75 76 * functions which need to be thread-safe: 77 * AddNewClient 78 * gprint and supporting functions must be thread safe (extensively 79 used...) 80 81 82 * race condition is irrelevant for this variable 83 static int ControllerStatus = FALSE; 84 85 static int stdin_cntl, stdout_cntl, stderr_cntl; 86 GetJobOutput -> CheckControllerJob -> CheckController -> controllerThread 87 ControllerCommand -> controllerThread / clientThread 88 CheckControllerOutput -> controllerThread / clientThread 89 StartController -> controllerThread / clientThread 90 StopController 91 92 93 94 static IOBuffer stdout_buffer; 95 static IOBuffer stderr_buffer; 96 static int ControllerPID = 0; 97 98 /* local static variables to track the controller host properties */ 99 static Host *hosts = NULL; 100 static int Nhosts = 0; 101 static int NHOSTS = 0; 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 1 125 2 126 PanTasks Client / Server design -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/pantasks.c.in
r16453 r23594 10 10 void program_init (int *argc, char **argv) { 11 11 12 pthread_t jobsThread; 13 pthread_t tasksThread; 12 pthread_t JobsAndTasksThread; 14 13 pthread_t controllerThread; 15 14 … … 50 49 51 50 /* start up the background threads here */ 52 pthread_create (&tasksThread, NULL, &CheckTasksThread, NULL); 53 pthread_create (&jobsThread, NULL, &CheckJobsThread, NULL); 54 pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL); 51 // pthread_create (&tasksThread, NULL, &CheckTasksThread, NULL); 52 // pthread_create (&jobsThread, NULL, &CheckJobsThread, NULL); 53 pthread_create (&JobsAndTasksThread, NULL, &CheckJobsAndTasksThread, NULL); 54 pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL); 55 55 return; 56 56 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/pantasks_server.c.in
r16453 r23594 17 17 18 18 char log_stdout[128], log_stderr[128]; 19 pthread_t jobsThread; 20 pthread_t tasksThread; 21 pthread_t inputsThread; 19 pthread_t JobsAndTasksThread; 22 20 pthread_t clientsThread; 23 21 pthread_t controllerThread; … … 63 61 64 62 /* start up the background threads here */ 65 pthread_create (&clientsThread, NULL, &ListenClients, NULL); 66 pthread_create (&tasksThread, NULL, &CheckTasksThread, NULL); 67 pthread_create (&jobsThread, NULL, &CheckJobsThread, NULL); 68 pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL); 69 pthread_create (&inputsThread, NULL, &CheckInputsThread, NULL); 63 pthread_create (&clientsThread, NULL, &ListenClients, NULL); 64 pthread_create (&JobsAndTasksThread, NULL, &CheckJobsAndTasksThread, NULL); 65 pthread_create (&controllerThread, NULL, &CheckControllerThread, NULL); 70 66 71 67 /* in this loop, we listen for incoming connections, validate, and -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/server.c
r16463 r23594 5 5 int input PROTO((int, char **)); 6 6 int module PROTO((int, char **)); 7 int server_load PROTO((int, char **));8 7 int server_run PROTO((int, char **)); 9 8 int server_stop PROTO((int, char **)); … … 20 19 {1, "input", input, "load input file on server"}, 21 20 {1, "module", module, "load module file on server"}, 22 {1, "load", server_load, "load input file on server"},23 21 {1, "run", server_run, "run scheduler"}, 24 22 {1, "stop", server_stop, "stop scheduler"}, -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/server_run.c
r11084 r23594 11 11 CheckJobsSetState (TRUE); 12 12 CheckControllerSetState (TRUE); 13 CheckInputsSetState (TRUE);14 13 return (TRUE); 15 14 } … … 23 22 24 23 CheckTasksSetState (FALSE); 25 // CheckJobsSetState (FALSE);26 // CheckControllerSetState (FALSE);27 CheckInputsSetState (FALSE);28 24 return (TRUE); 29 25 } … … 39 35 CheckJobsSetState (FALSE); 40 36 CheckControllerSetState (FALSE); 41 CheckInputsSetState (FALSE);42 37 return (TRUE); 43 38 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/showtask.c
r12468 r23594 8 8 } 9 9 10 JobTaskLock(); 10 11 ShowTask (argv[1]); 12 JobTaskUnlock(); 13 11 14 return (TRUE); 12 15 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/status_server.c
r16012 r23594 11 11 if ((N = get_argument (argc, argv, "-tasks"))) { 12 12 remove_argument (N, &argc, argv); 13 JobTaskLock(); 13 14 ListTasks (FALSE); 15 JobTaskUnlock(); 14 16 return (TRUE); 15 17 } … … 17 19 if ((N = get_argument (argc, argv, "-taskinfo"))) { 18 20 remove_argument (N, &argc, argv); 21 JobTaskLock(); 19 22 ListTasks (TRUE); 23 JobTaskUnlock(); 20 24 return (TRUE); 21 25 } … … 23 27 if ((N = get_argument (argc, argv, "-taskstats"))) { 24 28 remove_argument (N, &argc, argv); 29 JobTaskLock(); 25 30 if (argc == 2) { 26 31 ListTaskStats (argv[N]); … … 28 33 ListTaskStats (NULL); 29 34 } 35 JobTaskUnlock(); 30 36 return (TRUE); 31 37 } … … 33 39 if ((N = get_argument (argc, argv, "-taskstatsreset"))) { 34 40 remove_argument (N, &argc, argv); 41 JobTaskLock(); 35 42 if (argc == 2) { 36 43 ResetTaskStats (argv[N]); … … 38 45 ResetTaskStats (NULL); 39 46 } 47 JobTaskUnlock(); 40 48 return (TRUE); 41 49 } … … 56 64 gprint (GP_LOG, " Controller is stopped\n"); 57 65 } 66 67 JobTaskLock(); 58 68 ListTasks (FALSE); 59 69 ListJobs (); 70 JobTaskUnlock(); 71 72 ControlLock(__func__); 73 PrintControllerBusyJobs(); 74 ControlUnlock(__func__); 75 60 76 return (TRUE); 61 77 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task.c
r14590 r23594 11 11 if (argc != 2) goto usage; 12 12 13 JobTaskLock(); 13 14 task = FindTask (argv[1]); 14 15 if (task == NULL) { /**** new task ****/ … … 18 19 SetNewTask (task); 19 20 } 21 JobTaskUnlock(); 22 20 23 /* While a task is being defined, it is removed from the task list. The new task is added to the task list 21 24 when the definition process is complete. … … 55 58 56 59 case TASK_END: 57 /* I need to add in a test here to see if all task elements58 have been defined. delete the task if not */59 60 free (input); 60 61 /* validate the new task: all mandatory elements defined? */ … … 63 64 return (FALSE); 64 65 } 66 JobTaskLock(); 65 67 RegisterNewTask (); 68 JobTaskUnlock(); 66 69 return (TRUE); 67 70 break; -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_active.c
r10734 r23594 7 7 if (argc != 2) goto usage; 8 8 9 JobTaskLock(); 9 10 task = GetNewTask (); 10 11 if (task == NULL) { 11 12 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 13 JobTaskUnlock(); 12 14 return (FALSE); 13 15 } … … 15 17 if (!strcasecmp (argv[1], "true")) { 16 18 task[0].active = TRUE; 19 JobTaskUnlock(); 17 20 return (TRUE); 18 21 } 19 22 if (!strcasecmp (argv[1], "false")) { 20 23 task[0].active = FALSE; 24 JobTaskUnlock(); 21 25 return (TRUE); 22 26 } 23 27 24 28 gprint (GP_ERR, "ERROR: invalid option: %s\n", argv[1]); 29 JobTaskUnlock(); 25 30 return (FALSE); 26 31 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_command.c
r7917 r23594 12 12 } 13 13 14 JobTaskLock(); 14 15 task = GetNewTask (); 15 16 if (task == NULL) { … … 17 18 if (task == NULL) { 18 19 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 20 JobTaskUnlock(); 19 21 return (FALSE); 20 22 } … … 35 37 task[0].argv[i] = strcreate (argv[i+1]); 36 38 } 39 JobTaskUnlock(); 37 40 return (TRUE); 38 41 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_host.c
r7917 r23594 22 22 23 23 task = GetNewTask (); 24 JobTaskLock(); 24 25 if (task == NULL) { 25 26 task = GetActiveTask (); 26 27 if (task == NULL) { 27 28 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 29 JobTaskUnlock(); 28 30 return (FALSE); 29 31 } … … 34 36 task[0].host = NULL; 35 37 36 if (!strcasecmp (argv[1], "LOCAL")) return (TRUE); 38 if (!strcasecmp (argv[1], "LOCAL")) { 39 JobTaskUnlock(); 40 return (TRUE); 41 } 37 42 38 43 task[0].host = strcreate (argv[1]); 44 JobTaskUnlock(); 39 45 return (TRUE); 40 46 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_macros.c
r10647 r23594 22 22 } 23 23 24 JobTaskLock(); 24 25 task = GetNewTask (); 25 26 if (task == NULL) { 26 27 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 28 JobTaskUnlock(); 27 29 return (FALSE); 28 30 } … … 135 137 free (input); 136 138 REALLOCATE (macro[0].line, char *, MAX (1, macro[0].Nlines)); 139 JobTaskUnlock(); 137 140 return (TRUE); 138 141 } … … 148 151 } 149 152 } 153 JobTaskUnlock(); 150 154 return (TRUE); 151 155 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_nmax.c
r11055 r23594 7 7 if (argc != 2) goto usage; 8 8 9 JobTaskLock(); 9 10 task = GetNewTask (); 10 11 if (task == NULL) { 11 12 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 13 JobTaskUnlock(); 12 14 return (FALSE); 13 15 } 14 16 15 17 task[0].Nmax = atoi (argv[1]); 18 JobTaskUnlock(); 16 19 return (TRUE); 17 20 … … 27 30 if (argc != 2) goto usage; 28 31 32 JobTaskLock(); 29 33 task = GetNewTask (); 30 34 if (task == NULL) { 31 35 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 36 JobTaskUnlock(); 32 37 return (FALSE); 33 38 } 34 39 35 40 task[0].NpendingMax = atoi (argv[1]); 41 JobTaskUnlock(); 36 42 return (TRUE); 37 43 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_options.c
r8129 r23594 12 12 } 13 13 14 JobTaskLock(); 14 15 task = GetNewTask (); 15 16 if (task == NULL) { … … 17 18 if (task == NULL) { 18 19 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 20 JobTaskUnlock(); 19 21 return (FALSE); 20 22 } … … 35 37 task[0].optv[i] = strcreate (argv[i+1]); 36 38 } 39 JobTaskUnlock(); 37 40 return (TRUE); 38 41 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_periods.c
r7917 r23594 40 40 } 41 41 42 JobTaskLock(); 42 43 task = GetNewTask (); 43 44 if (task == NULL) { … … 45 46 if (task == NULL) { 46 47 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 48 JobTaskUnlock(); 47 49 return (FALSE); 48 50 } … … 53 55 if (Timeout) task[0].timeout_period = TimeoutValue; 54 56 57 JobTaskUnlock(); 55 58 return (TRUE); 56 59 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_stdout.c
r12332 r23594 11 11 } 12 12 13 JobTaskLock(); 13 14 task = GetNewTask (); 14 15 if (task == NULL) { … … 16 17 if (task == NULL) { 17 18 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 19 JobTaskUnlock(); 18 20 return (FALSE); 19 21 } … … 21 23 if (task[0].stdout_dump != NULL) free (task[0].stdout_dump); 22 24 task[0].stdout_dump = strcreate (argv[1]); 25 JobTaskUnlock(); 23 26 return (TRUE); 24 27 } … … 34 37 } 35 38 39 JobTaskLock(); 36 40 task = GetNewTask (); 37 41 if (task == NULL) { … … 39 43 if (task == NULL) { 40 44 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 45 JobTaskUnlock(); 41 46 return (FALSE); 42 47 } … … 44 49 if (task[0].stderr_dump != NULL) free (task[0].stderr_dump); 45 50 task[0].stderr_dump = strcreate (argv[1]); 51 JobTaskUnlock(); 46 52 return (TRUE); 47 53 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/task_trange.c
r15487 r23594 12 12 if (argc != 1) goto usage; 13 13 14 JobTaskLock(); 14 15 task = GetNewTask (); 15 16 if (task == NULL) { 16 17 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 18 JobTaskUnlock(); 17 19 return (FALSE); 18 20 } … … 20 22 task[0].Nranges = 0; 21 23 REALLOCATE (task[0].ranges, TimeRange, 1); 24 JobTaskUnlock(); 22 25 return (TRUE); 23 26 } … … 40 43 41 44 if (argc != 3) goto usage; 42 43 task = GetNewTask ();44 if (task == NULL) {45 gprint (GP_ERR, "ERROR: not defining or running a task\n");46 return (FALSE);47 }48 45 49 46 /* test for Mon[@HH:MM:SS] - both must match */ … … 83 80 84 81 valid: 82 JobTaskLock(); 83 task = GetNewTask (); 84 if (task == NULL) { 85 gprint (GP_ERR, "ERROR: not defining or running a task\n"); 86 JobTaskUnlock(); 87 return (FALSE); 88 } 89 85 90 N = task[0].Nranges; 86 91 task[0].Nranges ++; … … 88 93 89 94 task[0].ranges[N] = range; 95 JobTaskUnlock(); 90 96 return (TRUE); 91 97 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pantasks/thread_locks.c
r11084 r23594 1 1 # include "pantasks.h" 2 2 3 /* this mutex is used by the serialized threads */ 3 /* mutex to lock Client table operations */ 4 static pthread_mutex_t ClientMutex = PTHREAD_MUTEX_INITIALIZER; 4 5 5 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 6 7 void SerialThreadLock () { 8 pthread_mutex_lock (&mutex); 6 void ClientLock () { 7 pthread_mutex_lock (&ClientMutex); 9 8 } 10 9 11 void SerialThreadUnlock () {12 pthread_mutex_unlock (&mutex);10 void ClientUnlock () { 11 pthread_mutex_unlock (&ClientMutex); 13 12 } 14 13 14 /* mutex to lock Command / Multicommand operations */ 15 static pthread_mutex_t CommandMutex = PTHREAD_MUTEX_INITIALIZER; 16 17 void CommandLock () { 18 // fprintf (stderr, "command lock\n"); 19 pthread_mutex_lock (&CommandMutex); 20 } 21 22 void CommandUnlock () { 23 // fprintf (stderr, "command unlock\n"); 24 pthread_mutex_unlock (&CommandMutex); 25 } 26 27 /* mutex to lock Control operations */ 28 static pthread_mutex_t ControlMutex = PTHREAD_MUTEX_INITIALIZER; 29 30 void ControlLock (char *func) { 31 // fprintf (stderr, "control lock %s\n", func); 32 pthread_mutex_lock (&ControlMutex); 33 } 34 35 void ControlUnlock (char *func) { 36 // fprintf (stderr, "control unlock %s\n", func); 37 pthread_mutex_unlock (&ControlMutex); 38 } 39 40 /* mutex to lock Job / Task operations */ 41 static pthread_mutex_t JobTaskMutex = PTHREAD_MUTEX_INITIALIZER; 42 43 void JobTaskLock () { 44 // fprintf (stderr, "jobtask lock\n"); 45 pthread_mutex_lock (&JobTaskMutex); 46 } 47 48 void JobTaskUnlock () { 49 // fprintf (stderr, "jobtask unlock\n"); 50 pthread_mutex_unlock (&JobTaskMutex); 51 } 52 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pcontrol/JobOps.c
r21379 r23594 202 202 ALLOCATE (job, Job, 1); 203 203 204 job[0].JobID = NextJobID(); 205 if (job[0].JobID < 0) { 206 free (job); 207 return -1; 208 } 209 204 210 job[0].argc = argc; 205 211 job[0].argv = argv; … … 220 226 job[0].dtime = 0.0; 221 227 job[0].pid = 0; 222 223 job[0].JobID = NextJobID();224 228 job[0].host = NULL; 225 229 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/opihi/pcontrol/job.c
r19124 r23594 11 11 return (FALSE); 12 12 } 13 14 if (get_argument (argc, argv, "-h")) goto usage; 15 if (get_argument (argc, argv, "-help")) goto usage; 16 if (get_argument (argc, argv, "--help")) goto usage; 13 17 14 18 Host = NULL; … … 36 40 37 41 if (argc < 2) { 38 gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n");39 gprint (GP_ERR, " arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n");40 42 FREE (Host); 41 return (FALSE);43 goto usage; 42 44 } 43 45 … … 48 50 } 49 51 52 // a JobID < 0 mean the job was not accepted 50 53 JobID = AddJob (Host, Mode, Timeout, targc, targv); 51 54 gprint (GP_LOG, "JobID: %d\n", (int) JobID); 52 55 return (TRUE); 56 57 usage: 58 gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n"); 59 gprint (GP_ERR, " options: -host, +host, -timeout\n"); 60 gprint (GP_ERR, " arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n"); 61 return (FALSE); 53 62 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/ImageOps.c
r23344 r23594 297 297 mask = TRUE; 298 298 } 299 if (~finite(catalog[c].measure[m].dR) || ~finite(catalog[c].measure[m].dD)) mask = TRUE; 300 299 301 raw[i].mask = mask; 300 302 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/UpdateObjects.c
r21508 r23594 96 96 97 97 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 98 99 //exclude measurements which have non-finite astrometry 100 if (~finite(catalog[i].measure[m].dR) || ~finite(catalog[i].measure[m].dD)) continue; 98 101 99 102 // exclude measurements by previous outlier detection -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/bcatalog.c
r23344 r23594 8 8 int mask; 9 9 PhotCode *code; 10 int skipFew = skipPhotCodeKeep = skipPhotCodeSkip = skipTime = skipPhotFlag = skipSigmaLim = skipImagSelect = 0; 10 11 11 12 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? … … 23 24 /* exclude stars not in range or with too few measurements */ 24 25 for (i = 0; i < catalog[0].Naverage; i++) { 25 if (catalog[0].average[i].Nmeasure <= SRC_MEAS_TOOFEW) continue; 26 26 if (catalog[0].average[i].Nmeasure <= SRC_MEAS_TOOFEW) { 27 skipFew++; 28 continue; 29 } 30 27 31 /* start with all stars good */ 28 32 subcatalog[0].average[Naverage] = catalog[0].average[i]; … … 52 56 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 53 57 } 54 if (!found) continue; 58 if (!found) { 59 skipPhotCodeKeep++; 60 continue; 61 } 55 62 } 56 63 if (NphotcodesSkip > 0) { … … 60 67 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 61 68 } 62 if (found) continue; 69 if (found) { 70 skipPhotCodeSkip++; 71 continue; 72 } 63 73 } 64 74 65 75 /* select measurements by time */ 66 76 if (TimeSelect) { 67 if (catalog[0].measure[offset].t < TSTART) continue; 68 if (catalog[0].measure[offset].t > TSTOP) continue; 77 if (catalog[0].measure[offset].t < TSTART) { 78 skipTime++; 79 continue; 80 } 81 if (catalog[0].measure[offset].t > TSTOP) { 82 skipTime++; 83 continue; 84 } 69 85 } 70 86 71 87 /* select measurements by quality */ 72 88 // XXX FIX THIS!! 73 89 // if (DophotSelect && (catalog[0].measure[offset].dophot != DophotValue)) continue; 74 90 75 91 /* select measurements by quality */ 76 92 if (PhotFlagSelect) { … … 81 97 mask = code[0].astromBadMask; 82 98 } 83 if (mask & catalog[0].measure[offset].photFlags) continue; 99 if (mask & catalog[0].measure[offset].photFlags) { 100 skipPhotFlag++; 101 continue; 102 } 84 103 } 85 104 86 105 /* select measurements by measurement error */ 87 if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) continue; 88 106 if ((SIGMA_LIM > 0) && (catalog[0].measure[offset].dM > SIGMA_LIM)) { 107 skipSigmaLim++; 108 continue; 109 } 110 89 111 /* select measurements by mag limit */ 90 112 if (ImagSelect) { 91 113 mag = PhotInst (&catalog[0].measure[offset]); 92 if (mag < ImagMin) continue; 93 if (mag > ImagMax) continue; 114 if (mag < ImagMin || mag > ImagMax) { 115 skipImagSelect++; 116 continue; 117 } 94 118 } 95 96 119 // re-assess on each run of relastro if a measurement should be used 97 120 … … 139 162 140 163 if (VERBOSE) { 164 fprintf(stderr, "Reasons for exclusion in bcatalog:\n"); 165 fprintf(stderr, "\ntoo few: %d \nphotCodeSkip: %d \nphotCodeKeep: %d \ntime: %d\n", 166 skipfew, skipPhotCodeKeep, skipPhotCodeSkip, skipTime); 167 fprintf(stderr, "photFlag: %d \nmagnitude error: %d \nImag: %d\n", 168 skipPhotFlag, skipSigmaLim, skipImagSelect); 169 } 170 171 if (VERBOSE) { 141 172 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 142 173 subcatalog[0].Naverage, subcatalog[0].Nmeasure); -
branches/cnb_branches/cnb_branch_20090301/PS-IPP-Config/lib/PS/IPP/Config.pm
r23352 r23594 388 388 } 389 389 390 return 1if defined $self->{nebulous}; # Already started390 return $self->{nebulous} if defined $self->{nebulous}; # Already started 391 391 392 392 my $server = metadataLookupStr( $self->{_siteConfig}, 'NEB_SERVER' ); # Nebulous server … … 398 398 my $neb = eval { Nebulous::Client->new( proxy => $server ); }; 399 399 if ($@ or not defined $neb) { 400 carp "Unable to find NEB_SERVER in camera configuration file.";400 carp "Unable to create a Nebulous::Client object with proxy => $server"; 401 401 return undef; 402 402 } … … 404 404 $self->{nebulous} = $neb; 405 405 406 return 1; 406 return $neb; 407 } 408 409 sub nebulous 410 { 411 my $self = shift; 412 carp "no parameters are allowed" if @_; 413 414 # check to see if we already have a live nebulous object 415 return $self->{nebulous} if defined $self->{nebulous}; 416 417 # if not, call _neb_start() and return the new object 418 return $self->_neb_start() or ( carp "Can't start Nebulous" and return undef ); 407 419 } 408 420 … … 421 433 422 434 if ($scheme eq 'neb') { 423 $self->_neb_start() or ( carp "Can't start Nebulous" and return undef ); 424 my $neb = $self->{nebulous}; # Nebulous handle 435 my $neb = $self->nebulous; # Nebulous handle 425 436 if ($create_if_doesnt_exist) { 426 437 my $status = eval { $neb->stat( $name ); }; … … 485 496 $scheme = lc($scheme); 486 497 if ($scheme eq 'neb') { 487 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 488 my $fh = eval { $self->{nebulous}->open_create( $name ); }; 498 my $fh = eval { $self->nebulous->open_create( $name ); }; 489 499 if ($@ or not defined $fh) { 490 500 carp "Unable to open/create Nebulous handle $name"; … … 524 534 $scheme = lc($scheme); 525 535 if ($scheme eq 'neb') { 526 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 527 my $fh = eval { $self->{nebulous}->open_create( $name ) }; 536 my $fh = eval { $self->nebulous->open_create( $name ) }; 528 537 if ($@ or not defined $fh) { 529 538 carp "Unable to open/create Nebulous handle $name"; … … 556 565 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 557 566 if (defined $scheme and lc($scheme) eq 'neb') { 558 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 559 $name = eval { $self->{nebulous}->create( $name ) }; 567 $name = eval { $self->nebulous->create( $name ) }; 560 568 if ($@ or not defined $name) { 561 569 carp "Unable to create Nebulous handle $name"; … … 575 583 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 576 584 if (defined $scheme and lc($scheme) eq 'neb') { 577 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 578 my $found = eval { $self->{nebulous}->find_instances( $name ); }; 585 my $found = eval { $self->nebulous->find_instances( $name ); }; 579 586 ( carp "Unable to find instances of Nebulous handle $name" and return undef ) if $@; 580 587 return (defined $found ? 1 : 0); … … 595 602 my $scheme = file_scheme($target); # The scheme, e.g., file://, path:// 596 603 if (defined $scheme and lc($scheme) eq 'neb') { 597 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 598 $target = eval { $self->{nebulous}->create( $target ); }; 604 $target = eval { $self->nebulous->create( $target ); }; 599 605 if ($@ or not defined $target) { 600 606 carp "Unable to create Nebulous handle"; … … 646 652 my $scheme = file_scheme($name); # The scheme, e.g., file://, path:// 647 653 if (defined $scheme and lc($scheme) eq 'neb') { 648 $self->_neb_start() or ( carp "Unable to start Nebulous" and return undef ); 649 $status = eval { $self->{nebulous}->delete( $name ); }; 654 $status = eval { $self->nebulous->delete( $name ); }; 650 655 ( carp "Unable to delete Nebulous handle $name" and return undef ) if $@; 651 656 } else { -
branches/cnb_branches/cnb_branch_20090301/dbconfig/changes.txt
r23352 r23594 740 740 ALTER TABLE diffSkyfile ADD COLUMN magicked TINYINT; 741 741 742 -- drop exi ting foreign key constraints742 -- drop existing foreign key constraints 743 743 ALTER TABLE diffInputSkyfile drop FOREIGN KEY diffInputSkyfile_ibfk_1; 744 744 ALTER TABLE diffInputSkyfile drop FOREIGN KEY diffInputSkyfile_ibfk_2; … … 836 836 show create table detResidImfile; 837 837 alter table detResidImfile drop foreign key detResidImfile_ibfk_3; 838 839 840 -- Version: 1.1.50 magic and distribution changes 841 842 ALTER TABLE magicDSRun ADD COLUMN label VARCHAR(64) after cam_id; 843 ALTER TABLE magicDSRun ADD KEY(label); 844 845 -- replace null values for magicked flags with zero 846 UPDATE rawImfile SET magicked = 0 WHERE magicked IS NULL; 847 UPDATE chipProcessedImfile SET magicked = 0 WHERE magicked IS NULL; 848 UPDATE warpSkyfile SET magicked = 0 WHERE magicked IS NULL; 849 UPDATE diffSkyfile SET magicked = 0 WHERE magicked IS NULL; 850 851 CREATE TABLE distRun ( 852 dist_id BIGINT AUTO_INCREMENT, 853 target_id BIGINT, 854 stage VARCHAR(64), 855 stage_id BIGINT, 856 label VARCHAR(64), 857 outroot VARCHAR(255), 858 clean TINYINT, 859 state VARCHAR(64), 860 time_stamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 861 fault SMALLINT, 862 PRIMARY KEY(dist_id), 863 KEY(state), 864 KEY(label), 865 FOREIGN KEY(target_id) REFERENCES distTarget(target_id) 866 ) ENGINE=innodb DEFAULT CHARSET=latin1; 867 868 CREATE TABLE distComponent ( 869 dist_id BIGINT, 870 component VARCHAR(64), 871 bytes INT, 872 md5sum VARCHAR(32), 873 state VARCHAR(64), 874 name VARCHAR(255), 875 fault SMALLINT, 876 PRIMARY KEY(dist_id, component), 877 KEY(state), 878 FOREIGN KEY(dist_id) REFERENCES distRun(dist_id) 879 ) ENGINE=innodb DEFAULT CHARSET=latin1; 880 881 882 -- change state fields to match the rest of the system 883 UPDATE magicRun SET state = 'new' WHERE state = 'run'; 884 UPDATE magicRun SET state = 'full' WHERE state = 'stop'; 885 UPDATE magicDSRun SET state = 'new' WHERE state = 'run'; 886 UPDATE magicDSRun SET state = 'full' WHERE state = 'stop'; 887 888 ALTER TABLE rawExp ADD COLUMN magicked TINYINT; 889 ALTER TABLE chipRun ADD COLUMN magicked TINYINT; 890 ALTER TABLE warpRun ADD COLUMN magicked TINYINT; 891 ALTER TABLE diffRun ADD COLUMN magicked TINYINT; 892 893 update rawExp SET magicked = 0; 894 update chipRun SET magicked = 0; 895 update warpRun SET magicked = 0; 896 update diffRun SET magicked = 0; 897 898 -- The following only applies to the gpc1 database (and recent copies) 899 update chipRun SET magicked = 1 where chip_id = 11955; 900 901 CREATE TABLE distTarget ( 902 target_id BIGINT AUTO_INCREMENT, 903 obs_mode VARCHAR(64), 904 stage VARCHAR(64), 905 clean TINYINT, 906 state VARCHAR(64), 907 comment VARCHAR(255), 908 PRIMARY KEY(target_id) 909 ) ENGINE=innodb DEFAULT CHARSET=latin1; 910 911 912 CREATE TABLE rcDSProduct ( 913 prod_id BIGINT AUTO_INCREMENT, 914 name VARCHAR(64), 915 dbname VARCHAR(64), 916 dbhost VARCHAR(64), 917 prod_root VARCHAR(255), 918 PRIMARY KEY(prod_id) 919 ) ENGINE=innodb DEFAULT CHARSET=latin1; 920 921 CREATE TABLE rcDestination ( 922 dest_id BIGINT AUTO_INCREMENT, 923 prod_id BIGINT, 924 name VARCHAR(64), 925 status_uri VARCHAR(255), 926 comment VARCHAR(255), 927 last_fileset VARCHAR(255), 928 state VARCHAR(64), 929 PRIMARY KEY(dest_id), 930 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 931 ) ENGINE=innodb DEFAULT CHARSET=latin1; 932 933 934 CREATE TABLE rcInterest ( 935 int_id BIGINT AUTO_INCREMENT, 936 dest_id BIGINT, 937 target_id BIGINT, 938 prod_id BIGINT, 939 state VARCHAR(64), 940 PRIMARY KEY(int_id), 941 FOREIGN KEY(dest_id) REFERENCES rcDestination(dest_id), 942 FOREIGN KEY(target_id) REFERENCES distTarget(target_id), 943 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 944 ) ENGINE=innodb DEFAULT CHARSET=latin1; 945 946 CREATE TABLE rcDSFileset ( 947 fs_id BIGINT AUTO_INCREMENT, 948 dist_id BIGINT, 949 prod_id BIGINT, 950 name VARCHAR(64), 951 state VARCHAR(64), 952 registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 953 PRIMARY KEY(fs_id), 954 FOREIGN KEY(dist_id) REFERENCES distRun(dist_id), 955 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 956 ) ENGINE=innodb DEFAULT CHARSET=latin1; 957 958 CREATE TABLE rcRun ( 959 rc_id BIGINT AUTO_INCREMENT, 960 fs_id BIGINT, 961 dest_id BIGINT, 962 state VARCHAR(64), 963 registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 964 PRIMARY KEY(rc_id), 965 FOREIGN KEY(fs_id) REFERENCES rcDSFileset(fs_id), 966 FOREIGN KEY(dest_id) REFERENCES rcDestination(dest_id) 967 ) ENGINE=innodb DEFAULT CHARSET=latin1; 968 -
branches/cnb_branches/cnb_branch_20090301/dbconfig/chip.md
r21310 r23594 11 11 tess_id STR 64 12 12 end_stage STR 64 # Key 13 magicked BOOL f 13 14 END 14 15 -
branches/cnb_branches/cnb_branch_20090301/dbconfig/config.md
r23352 r23594 2 2 pkg_name STR ippdb 3 3 pkg_namespace STR ippdb 4 pkg_version STR 1.1. 494 pkg_version STR 1.1.50 5 5 END -
branches/cnb_branches/cnb_branch_20090301/dbconfig/diff.md
r21310 r23594 11 11 tess_id STR 64 # Key 12 12 exp_id S64 0 # fkey(exp_id) ref rawExp(exp_id) 13 magicked BOOL f 13 14 END 14 15 -
branches/cnb_branches/cnb_branch_20090301/dbconfig/dist.md
r23352 r23594 3 3 stage STR 64 4 4 stage_id S64 0 5 chip_id S64 06 5 label STR 64 # Key 7 6 outroot STR 255 8 7 clean BOOL f 9 8 state STR 64 # Key 9 time_stamp UTC 0001-01-01T00:00:00Z 10 10 fault S16 0 11 11 END … … 21 21 END 22 22 23 distTarget METADATA 24 target_id S64 0 # Primary Key 25 obs_mode STR 64 26 clean BOOL f 27 state STR 64 28 comment STR 255 29 END 30 -
branches/cnb_branches/cnb_branch_20090301/dbconfig/ipp.m4
r17886 r23594 22 22 include(flatcorr.md) 23 23 include(pstamp.md) 24 include(dist.md) -
branches/cnb_branches/cnb_branch_20090301/dbconfig/magic.md
r20973 r23594 42 42 43 43 magicDSRun METADATA 44 magic_ds_id S64 0 # Primary Key fkey(magic_ds_id)44 magic_ds_id S64 0 # Primary Key 45 45 magic_id S64 0 # Primary Key fkey(magic_id) ref magicRun(magic_id) 46 46 state STR 0 # Key … … 48 48 stage_id S64 0 49 49 cam_id S64 0 50 label STR 64 # key 50 51 outroot STR 255 51 52 recoveryroot STR 255 … … 55 56 56 57 magicDSFile METADATA 57 magic_ds_id S64 0 # Primary Key 58 magic_ds_id S64 0 # Primary Key fkey(magic_ds_id) ref magicDSRun(magic_ds_id) 58 59 component STR 64 59 60 backup_path_base STR 255 -
branches/cnb_branches/cnb_branch_20090301/dbconfig/tasks.md
r20973 r23594 171 171 fault S16 0 # Key NOT NULL 172 172 epoch UTC 0001-01-01T00:00:00Z 173 magicked BOOL f 173 174 END 174 175 … … 235 236 moon_alt F32 0.0 236 237 moon_phase F32 0.0 237 ignored BOOL FALSE238 ignored BOOL f 238 239 hostname STR 64 239 240 fault S16 0 # Key NOT NULL -
branches/cnb_branches/cnb_branch_20090301/dbconfig/warp.md
r21310 r23594 21 21 end_stage STR 64 # Key 22 22 registered TAI NULL 23 # if magic is T then look for the exp_id in the magic output tables 23 magicked BOOL f 24 24 END 25 25 -
branches/cnb_branches/cnb_branch_20090301/glueforge/templates/psdb/configure_ac.tt
r14443 r23594 40 40 CFLAGS=${TMP_CFLAGS} 41 41 42 43 42 AC_PATH_PROG([PERL], [perl], [missing]) 44 43 if test "$PERL" = "missing" ; then … … 46 45 fi 47 46 48 AC_PATH_PROG([DOXYGEN], [doxygen], []) 47 AC_ARG_ENABLE(doxygen, 48 [AS_HELP_STRING(--enable-doxygen,doxygen-erated documentation)], 49 [AC_MSG_RESULT(doxygen enabled) 50 AC_PATH_PROG([DOXYGEN], [doxygen], [])], 51 [AC_MSG_RESULT(doxygen disabled)]) 49 52 AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) 50 53 -
branches/cnb_branches/cnb_branch_20090301/ippMonitor/raw/ipp.php
r21137 r23594 40 40 41 41 // make this a DB lookup 42 $sql = "SELECT projname FROM projects ";42 $sql = "SELECT projname FROM projects order by projname"; 43 43 44 44 $qry = $db->query($sql); -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/chip_imfile.pl
r23352 r23594 35 35 } 36 36 37 my @ARGS = @ARGV; 38 37 39 # Parse the command-line arguments 38 40 my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose, 39 $no_update, $no_op, $redirect );41 $no_update, $no_op, $redirect, $magicked, $deburned ); 40 42 GetOptions( 41 43 'exp_id=s' => \$exp_id, # Exposure identifier … … 49 51 'reduction=s' => \$reduction, # Reduction class 50 52 'run-state=s' => \$run_state, # current state of the run (new, update) 53 'magicked' => \$magicked, # magicked state of input file 54 'deburned=s' => \$deburned, # does deburned image exist? 51 55 'threads=s' => \$threads, # Number of threads to use for ppImage 52 56 'verbose' => \$verbose, # Print to stdout … … 77 81 print STDOUT "\n\n"; 78 82 print STDOUT "Starting script $0 on $host\n\n"; 79 print STDOUT " COMMAND IS: @ARGV\n\n";83 print STDOUT "FULL COMMAND: $0 @ARGS\n\n"; 80 84 } 81 85 … … 123 127 my $command; 124 128 my $do_stats; 129 130 ## get the ppImage recipe for this camera and CHIP reduction 131 $command = "$ppConfigDump -camera $camera -dump-recipe PPIMAGE -recipe PPIMAGE $recipe_ppImage -"; 132 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 133 run(command => $command, verbose => $verbose); 134 unless ($success) { 135 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 137 } 138 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 139 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR); 140 141 ## XXX make the feature more general? 142 my $useDeburnedImage = metadataLookupBool($recipeData, 'USE.DEBURNED.IMAGE'); 143 if ($useDeburnedImage && $deburned) { 144 $uri =~ s/fits$/burn.fits/; 145 &my_die("Couldn't find deburned input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri); 146 } 125 147 126 148 if ($run_state eq "new") { … … 150 172 } 151 173 152 my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =174 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 175 run(command => $command, verbose => $verbose); 154 176 unless ($success) { … … 156 178 &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code); 157 179 } 158 159 ## get the ppImage recipe for this camera and CHIP reduction160 $command = "$ppConfigDump -camera $camera -dump-recipe PPIMAGE -recipe PPIMAGE $recipe_ppImage -";161 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =162 run(command => $command, verbose => $verbose);163 unless ($success) {164 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);165 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);166 }167 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or168 &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);169 180 170 181 ## allow the output images to be optional, depending on the recipe / reduction class … … 215 226 $command .= " -uri $outputImage"; 216 227 $command .= " -path_base $outroot"; 228 $command .= " -magicked" if $magicked; 217 229 $command .= " -hostname $host" if defined $host; 218 230 $command .= " -dbname $dbname" if defined $dbname; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_norm_apply.pl
r23352 r23594 89 89 'darkmask' => 'mask', 90 90 'flatmask' => 'mask', 91 'ctemask' => 'mask', 91 92 }; 92 93 -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_norm_calc.pl
r23352 r23594 81 81 'darkmask' => 0, 82 82 'flatmask' => 0, 83 'ctemask' => 0, 83 84 }; 84 85 -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_process_imfile.pl
r23352 r23594 79 79 'DARK' => undef, 80 80 'DARK_PREMASK' => undef, 81 'CTEMASK' => undef, 81 82 'SHUTTER' => 'PPIMAGE.OUTPUT.DETREND', 82 83 'FLAT_PREMASK' => 'PPIMAGE.OUTPUT.DETREND', -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_resid_exp.pl
r23352 r23594 124 124 # write the normalizations to a file as a metadata config file in the form: class_id F32 value 125 125 # XXX a possible optimization: if there is only one imfile, skip normalization 126 # Correcting the resid imfiles and stats requires us to *divide* by the normalization 127 # we do this by inverting the normalization here: 126 128 my $normsFile; 127 129 ($normsFile, $normsName) = tempfile( "/tmp/$exp_tag.detresid.$det_id.$iter.norms.XXXX", UNLINK => !$save_temps ); … … 129 131 foreach my $norm (@$normsMD) { 130 132 my $class_id = $norm->{class_id}; 131 my $normalization =$norm->{norm};133 my $normalization = 1.0 / $norm->{norm}; 132 134 133 135 $norms{$class_id} = $normalization; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_resid_imfile.pl
r23352 r23594 114 114 'darkmask' => '-mask', # Specify the mask frame 115 115 'flatmask' => '-mask', # Specify the mask frame 116 'ctemask' => '-mask', # Specify the mask frame 116 117 }; 117 118 … … 119 120 my $FILERULES = { 'FLATMASK' => 'PPIMAGE.OUTPUT.RESID', 120 121 'DARKMASK' => 'PPIMAGE.OUTPUT.RESID', 122 'CTEMASK' => 'PPIMAGE.OUTPUT.RESID', 121 123 'MASK' => 'PPIMAGE.OUTPUT.RESID', 122 124 'BIAS' => 'PPIMAGE.OUTPUT.RESID', -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/detrend_stack.pl
r23352 r23594 75 75 my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK', 76 76 'DARKMASK' => 'PPMERGE.OUTPUT.MASK', 77 'CTEMASK' => 'PPMERGE.OUTPUT.MASK', 77 78 'MASK' => 'PPMERGE.OUTPUT.MASK', 78 79 'BIAS' => 'PPMERGE.OUTPUT.BIAS', … … 97 98 my $STATRECIPES = {'FLATMASK' => 'DETSTATS', 98 99 'DARKMASK' => 'DETSTATS', 100 'CTEMASK' => 'DETSTATS', 99 101 'MASK' => 'DETSTATS', 100 102 'BIAS' => 'DETSTATS', -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/diff_skycell.pl
r23352 r23594 91 91 92 92 # Identify the input and the template 93 my ($input, $inputMask, $inputVariance, $inputPath ); # Input files and path93 my ($input, $inputMask, $inputVariance, $inputPath, $inputSources); # Input files and path 94 94 my ($template, $templateMask, $templateVariance, $templatePath, $templateSources); # Template files and path 95 95 my $tess_id; # Tesselation identifier 96 96 my $camera; # Camera 97 my $magicked_0; 98 my $magicked_1; 97 99 foreach my $file (@$files) { 98 100 if (defined $file->{template} and $file->{template}) { … … 103 105 $templateVariance = "PPSTACK.OUTPUT.VARIANCE"; 104 106 $templateSources = "PSPHOT.OUT.CMF.MEF"; ## this must be consistent with the value in stack_skycell.pl:161 107 # template is a stack so it doesn't need to be magicked 108 $magicked_1 = 1; 105 109 ## use an explicit stack name for psphot output objects 106 110 } else { … … 108 112 $templateVariance = "PSWARP.OUTPUT.VARIANCE"; 109 113 $templateSources = "PSWARP.OUTPUT.SOURCES"; 114 $magicked_1 = $file->{magicked}; 110 115 } 111 116 } else { 112 117 $input = $file->{uri}; 113 118 $inputPath = $file->{path_base}; 119 $magicked_0 = $file->{magicked}; # if input is a stack the output can't be "magicked" 114 120 if ($file->{warp_id} == 0) { 115 121 $inputMask = "PPSTACK.OUTPUT.MASK"; 116 122 $inputVariance = "PPSTACK.OUTPUT.VARIANCE"; 123 $inputSources = "PSPHOT.OUT.CMF.MEF"; ## this must be consistent with the value in stack_skycell.pl:161 117 124 } else { 118 125 $inputMask = "PSWARP.OUTPUT.MASK"; 119 126 $inputVariance = "PSWARP.OUTPUT.VARIANCE"; 127 $inputSources = "PSWARP.OUTPUT.SOURCES"; 120 128 } 121 129 } … … 144 152 &my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera; 145 153 $ipprc->define_camera($camera); 154 155 # Compute the magicked status of the output. 156 # The output file will be considered magicked if the input has been magicked and the 157 # template is either a stack or a warp that has been magicked. 158 # note that difftool -inputskyfile outputs the magicked boolean as an int not T or F 159 # because the output is constructed from a union of two selects 160 my $magicked = $magicked_0 && $magicked_1; 146 161 147 162 # Recipes to use based on reduction class … … 160 175 # print "inputVariance: $inputVariance\n"; 161 176 # print "templateSources: $templateSources\n"; 177 # print "inputSources: $inputSources\n"; 178 179 $inputMask = $ipprc->filename($inputMask, $inputPath); 180 $inputVariance = $ipprc->filename($inputVariance, $inputPath); 181 $inputSources = $ipprc->filename($inputSources, $inputPath); 162 182 163 183 $templateMask = $ipprc->filename($templateMask, $templatePath); 164 $inputMask = $ipprc->filename($inputMask, $inputPath);165 184 $templateVariance = $ipprc->filename($templateVariance, $templatePath); 166 $inputVariance = $ipprc->filename($inputVariance, $inputPath);167 185 $templateSources = $ipprc->filename($templateSources, $templatePath); 168 186 … … 174 192 print "inputVariance: $inputVariance\n"; 175 193 print "templateSources: $templateSources\n"; 194 print "inputSources: $inputSources\n"; 176 195 177 196 &my_die("Couldn't find input: $template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template); 178 197 &my_die("Couldn't find input: $templateMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask); 179 198 &my_die("Couldn't find input: $templateVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance); 199 &my_die("Couldn't find input: $templateSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources); 180 200 &my_die("Couldn't find input: $input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input); 181 201 &my_die("Couldn't find input: $inputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask); 182 202 &my_die("Couldn't find input: $inputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance); 183 &my_die("Couldn't find input: $ templateSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources);203 &my_die("Couldn't find input: $inputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources); 184 204 185 205 # Get the output filenames … … 198 218 # Perform subtraction 199 219 unless ($no_op) { 200 my $command = "$ppSub $input $template $outroot"; 220 my $command = "$ppSub $outroot"; 221 $command .= " -inimage $input"; 222 $command .= " -refimage $template"; 201 223 $command .= " -inmask $inputMask"; 202 224 $command .= " -refmask $templateMask"; 203 225 $command .= " -invariance $inputVariance"; 204 226 $command .= " -refvariance $templateVariance"; 227 $command .= " -insources $inputSources"; 228 $command .= " -refsources $templateSources"; 205 229 $command .= " -stats $outputStats"; 206 230 $command .= " -threads $threads" if defined $threads; … … 211 235 $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF"; 212 236 $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF"; 213 $command .= " -sources $templateSources";214 237 $command .= " -photometry"; 215 238 $command .= " -tracedest $traceDest -log $logDest"; … … 255 278 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -uri $outputName -path_base $outroot"; 256 279 $command .= " $cmdflags"; 280 $command .= " -magicked" if $magicked; 257 281 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 258 282 $command .= " -hostname $host" if defined $host; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/dist_component.pl
r23352 r23594 40 40 my ($dist_id, $camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $clean); 41 41 my ($outroot, $run_state, $data_state, $magicked); 42 my ($dbname, $save_temps, $verbose, $no_update, $ no_op, $logfile);42 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 43 43 44 44 GetOptions( 45 'dist_id=s' => \$dist_id,# Magic destreakrun identifier45 'dist_id=s' => \$dist_id, # distribution run identifier 46 46 'camera=s' => \$camera, # camera for evaluating file rules 47 47 'stage=s' => \$stage, # raw, chip, warp, or diff … … 52 52 'state=s' => \$run_state, # state of the run 53 53 'data_state=s' => \$data_state, # data_state for this component 54 'magicked =s' => \$magicked, # data_state for this component54 'magicked' => \$magicked, # magicked state for this component 55 55 'outroot=s' => \$outroot, # "directory" for outputs 56 'clean =s'=> \$clean, # create clean distribution56 'clean' => \$clean, # create clean distribution 57 57 'save-temps' => \$save_temps, # Save temporary files? 58 58 'dbname=s' => \$dbname, # Database name 59 59 'verbose' => \$verbose, # Print stuff? 60 60 'no-update' => \$no_update, # Don't update the database? 61 'no-op' => \$no_op, # Don't do any operations?62 61 'logfile=s' => \$logfile, 63 62 ) or pod2usage( 2 ); … … 86 85 my $basename = basename($path_base); 87 86 88 #89 # are we creating a clean distribution?90 if (defined($clean) and ($clean eq "T")) {91 $clean = 1;92 } else {93 $clean = 0;94 }95 96 87 # making a clean bundle of raw images doesn't make sense 97 88 if (($stage eq "raw") and $clean) { … … 99 90 &my_die("cannot create clean run at raw stage", $dist_id, $component, $PS_EXIT_CONFIG_ERROR); 100 91 } 101 102 92 103 93 # create the output directories if it is not a nebulous path and it doesn't exist … … 134 124 foreach my $file (@$file_list) { 135 125 my $base = basename($file); 126 my $path = $ipprc->file_resolve($file); 127 # if file is not found, just skip it. 128 # This is not always the right thing to do. 129 # For example if warpSkyfile is ignored, there won't be many of the data products 130 # the new config dump will only list the files actually produced. 131 next if !$path; 132 136 133 push @base_list, $base; 137 my $path = $ipprc->file_resolve($file);138 134 symlink $path, "$tmpdir/$base"; 139 135 } … … 142 138 143 139 # Here is where we determine whether or not a GPC1 image can be released. 144 145 if ($magicked and ($magicked eq "F")) {146 $magicked = 0;147 }148 140 149 141 if ($camera eq "GPC1" and !$magicked) { … … 181 173 $command .= " -chip_mask $mask" if ($stage eq 'chip' and $mask); 182 174 $command .= " -weight $variance" if $variance; 183 unless (defined $no_op) { 184 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 185 run(command => $command, verbose => $verbose); 186 unless ($success) { 187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 188 &my_die("Unable to perform $command: $error_code", $dist_id, $component, $error_code); 189 } 190 } else { 191 print "skipping command $command\n"; 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 176 run(command => $command, verbose => $verbose); 177 unless ($success) { 178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to perform $command: $error_code", $dist_id, $component, $error_code); 192 180 } 193 181 } … … 207 195 my $command = "tar -C $tmpdir -czhf $tarfile ."; 208 196 209 unless (defined $no_op) { 210 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 211 run(command => $command, verbose => $verbose); 212 unless ($success) { 213 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 214 &my_die("Unable to perform $command: $error_code", $dist_id, $component, $error_code); 215 } 216 } else { 217 print "skipping command $command\n"; 197 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 198 run(command => $command, verbose => $verbose); 199 unless ($success) { 200 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 201 &my_die("Unable to perform $command: $error_code", $dist_id, $component, $error_code); 218 202 } 219 203 … … 227 211 $bytes = $finfo[7]; 228 212 229 if (!$save_temps) { 230 # delete the temp directory and it's contents 231 system "rm -r $tmpdir"; 232 } 213 delete_tmpdir($tmpdir); 233 214 } 234 215 { … … 265 246 # TODO: these data will eventually come from the CONFIG dump 266 247 267 my $fh; 268 open $fh, "/data/ipp004.0/home/bills/ipp/ippScripts/scripts/clean.mdc" or 269 &my_die("cannot find clean.mdc", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR); 270 271 my @data = <$fh>; 272 my $clean_mdc = join "", @data; 248 my $clean_mdc = get_legacy_file_mdc(); 273 249 274 250 my $mdlist = $mdcParser->parse($clean_mdc) or … … 342 318 } 343 319 320 delete_tmpdir(); 321 344 322 carp($msg); 345 323 exit $exit_code; 346 324 } 347 325 326 sub delete_tmpdir 327 { 328 if (!$save_temps) { 329 system "rm -r $tmpdir"; 330 } 331 } 332 333 # list of output data products for runs that were made before the configuration re-work 334 sub get_legacy_file_mdc 335 { 336 my $list = 337 " 338 # 339 # interesting things we might want to save in this file 340 # 1. whether file is to be distributed in 'clean' mode 341 # 2. whether file is to be cleaned (this should be the same thing) 342 # 3. type of file 'no, not our business, precious' 343 344 # this data should probably be computed by the relevant program and saved as part 345 # of the configuration dump that is output. 346 347 348 PROD_LIST MULTI 349 350 PROD_LIST METADATA 351 STAGE STR RAW 352 # there is isn't really a file rule for raw images 353 DUMMY BOOL F 354 END 355 356 # list of data products for a gpc1 chipProcessedImfile (made by ppImage) 357 PROD_LIST METADATA 358 STAGE STR CHIP 359 PPIMAGE.CONFIG BOOL T 360 # PPIMAGE.CHIP BOOL F 361 # PPIMAGE.CHIP.MASK BOOL F 362 # PPIMAGE.CHIP.VARIANCE BOOL F 363 PPIMAGE.BIN1 BOOL T 364 PPIMAGE.BIN2 BOOL T 365 PSPHOT.OUT.CMF.SPL BOOL T 366 PSPHOT.BACKMDL BOOL T 367 PPIMAGE.STATS BOOL T 368 LOG.IMFILE BOOL T 369 TRACE.IMFILE BOOL T 370 # where do we put exposure level data such as LOG.EXP ? 371 END 372 # exposure level output products from camera processing made by psastro and ppImage (jpegs) 373 PROD_LIST METADATA 374 STAGE STR CAM 375 PSASTRO.CONFIG BOOL T 376 PSASTRO.OUTPUT BOOL T 377 PSASTRO.STATS BOOL T 378 PPIMAGE.JPEG1 BOOL T 379 PPIMAGE.JPEG2 BOOL T 380 LOG.EXP BOOL T 381 TRACE.EXP BOOL T 382 END 383 # chip lelel output products from camera processing made by psastro 384 PROD_LIST METADATA 385 STAGE STR CAM_CHIP 386 # PSASTRO.OUTPUT.MASK BOOL F 387 END 388 PROD_LIST METADATA 389 STAGE STR FAKE 390 # PPSIM.OUTPUT BOOL F 391 END 392 # list of data products for a gpc1 warpSkyfile (pswarp) 393 PROD_LIST METADATA 394 STAGE STR WARP 395 PSWARP.CONFIG BOOL T 396 # PSWARP.OUTPUT BOOL F 397 # PSWARP.OUTPUT.MASK BOOL F 398 # PSWARP.OUTPUT.VARIANCE BOOL F 399 PSWARP.OUTPUT.SOURCES BOOL T 400 PSPHOT.BACKMDL.MEF BOOL T 401 PSPHOT.PSF.SKY.SAVE BOOL T 402 SKYCELL.STATS BOOL T 403 SKYCELL.TEMPLATE BOOL T 404 LOG.EXP BOOL T 405 TRACE.EXP BOOL T 406 END 407 # outputs from diffRun (ppSub) 408 PROD_LIST METADATA 409 STAGE STR DIFF 410 PPSUB.CONFIG BOOL T 411 # PPSUB.OUTPUT BOOL F 412 # PPSUB.OUTPUT.MASK BOOL F 413 # PPSUB.OUTPUT.VARIANCE BOOL F 414 PPSUB.OUTPUT.KERNELS BOOL T 415 PPSUB.OUTPUT.JPEG1 BOOL T 416 PPSUB.OUTPUT.JPEG2 BOOL T 417 PSPHOT.OUT.CMF.MEF BOOL T 418 PSPHOT.BACKMDL.MEF BOOL T 419 SKYCELL.STATS BOOL T 420 LOG.EXP BOOL T 421 TRACE.EXP BOOL T 422 END 423 PROD_LIST METADATA 424 STAGE STR STACK 425 PPSTACK.CONFIG BOOL T 426 # PPSTACK.OUTPUT BOOL F 427 # PPSTACK.OUTPUT.MASK BOOL F 428 # PPSTACK.OUTPUT.VARIANCE BOOL F 429 PPSTACK.TARGET.PSF BOOL T 430 PSPHOT.OUT.CMF.MEF BOOL T 431 PSPHOT.BACKMDL.MEF BOOL T 432 SKYCELL.STATS BOOL T 433 PPSTACK.OUTPUT.JPEG1 BOOL T 434 PPSTACK.OUTPUT.JPEG2 BOOL T 435 LOG.EXP BOOL T 436 TRACE.EXP BOOL T 437 END 438 "; 439 return $list; 440 } 441 442 348 443 __END__ -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/register_imfile.pl
r23352 r23594 112 112 113 113 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 114 if (uc(&value_for_flag ($cmdflags, " -telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }115 if (uc(&value_for_flag ($cmdflags, " -inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }116 if (uc(&value_for_flag ($cmdflags, " -filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }117 if (uc(&value_for_flag ($cmdflags, " -class_id")) eq "NULL") { &my_die ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }118 if (uc(&value_for_flag ($cmdflags, " -exp_type")) eq "NULL") { &my_die ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); }114 if (uc(&value_for_flag ($cmdflags, "NULL", "-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 115 if (uc(&value_for_flag ($cmdflags, "NULL", "-inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 116 if (uc(&value_for_flag ($cmdflags, "NULL", "-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 117 if (uc(&value_for_flag ($cmdflags, "NULL", "-class_id")) eq "NULL") { &my_die ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 118 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 119 119 120 120 my $command = "$regtool -addprocessedimfile"; … … 128 128 129 129 # determine solar-system parameters 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");130 my $longitude = &value_for_flag($cmdflags, 0.0, "-longitude"); 131 my $latitude = &value_for_flag($cmdflags, 0.0, "-latitude"); 132 my $elevation = &value_for_flag($cmdflags, 0.0, "-elevation"); 133 my $ra = &value_for_flag($cmdflags, 0.0, "-ra"); 134 my $dec = &value_for_flag($cmdflags, 0.0, "-decl"); 135 my $dateobs = &value_for_flag($cmdflags, 0.0, "-dateobs"); 136 136 137 137 # if the needed data is available, pass it to sunmoon: … … 193 193 { 194 194 my $cmdflags = shift; 195 my $default = shift; 195 196 my $flag = shift; 196 197 197 my $value = 0.0;198 my $value = $default; 198 199 if ($cmdflags =~ m|$flag|) { 199 200 ($value) = $cmdflags =~ m|$flag\s+(\S+)|; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/stack_skycell.pl
r23352 r23594 203 203 # Perform stacking 204 204 unless ($no_op) { 205 my $command = "$ppStack $listName $outroot";205 my $command = "$ppStack -input $listName $outroot"; 206 206 $command .= " -stats $outputStats" if $do_stats;; 207 207 $command .= " -recipe PPSTACK $recipe_ppStack"; -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/summit_copy.pl
r23352 r23594 46 46 47 47 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 48 pod2usage( -msg => "Required options: --uri --filename --exp_name --inst --telescope --class --class_id --workdir",48 pod2usage( -msg => "Required options: --uri --filename --exp_name --inst --telescope --class --class_id", 49 49 -exitval => 3) 50 50 unless defined $uri … … 54 54 and defined $telescope 55 55 and defined $class 56 and defined $class_id 57 and defined $workdir; 56 and defined $class_id; 58 57 59 58 # Look for programs we need … … 107 106 $command .= " -class_id $class_id"; 108 107 $command .= " -uri $filename"; 109 $command .= " -workdir $workdir";108 # $command .= " -workdir $workdir"; 110 109 $command .= " -hostname $host"; 111 $command .= " -end_stage $end_stage" if defined $end_stage;110 # $command .= " -end_stage $end_stage" if defined $end_stage; 112 111 $command .= " -dbname $dbname" if defined $dbname; 113 112 -
branches/cnb_branches/cnb_branch_20090301/ippScripts/scripts/warp_skycell.pl
r23352 r23594 36 36 } 37 37 38 my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $ verbose, $no_update, $no_op, $redirect, $save_temps);38 my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $magicked, $verbose, $no_update, $no_op, $redirect, $save_temps); 39 39 GetOptions( 40 40 'warp_id|i=s' => \$warp_id, # Warp identifier … … 47 47 'threads=s' => \$threads, # Number of threads to use for pswarp 48 48 'run-state=s' => \$run_state, # 'new' or 'update' 49 'magicked' => \$magicked, # input run has been magicked already? 49 50 'verbose' => \$verbose, # Print to stdout 50 51 'no-update' => \$no_update, # Don't update the database? … … 246 247 $command .= " -tess_id $tess_dir"; 247 248 $command .= " -path_base $outroot"; # needed for logfile lookups 249 $command .= " -magicked" if $magicked; 248 250 249 251 $command .= " -uri $outputImage" if $accept; -
branches/cnb_branches/cnb_branch_20090301/ippTasks/Makefile.am
r23352 r23594 1 1 task_files = \ 2 detrend.mkruns.pro \3 2 detrend.norm.pro \ 4 3 detrend.process.pro \ … … 7 6 detrend.stack.pro \ 8 7 detrend.correct.pro \ 8 detrend.cleanup.pro \ 9 9 flatcorr.pro \ 10 10 automate.pro \ … … 36 36 simtest.flatcorr.config \ 37 37 simtest.flatcorr.auto \ 38 simtest.ctemask.config \ 39 simtest.ctemask.auto \ 38 40 simtest.stack.config \ 39 41 simtest.stack.auto -
branches/cnb_branches/cnb_branch_20090301/ippTasks/chip.pro
r23352 r23594 142 142 book getword chipPendingImfile $pageName exp_id -var EXP_ID 143 143 book getword chipPendingImfile $pageName exp_tag -var EXP_TAG 144 book getword chipPendingImfile $pageName raw_magicked -var RAW_MAGICKED 145 book getword chipPendingImfile $pageName deburned -var DEBURNED 144 146 book getword chipPendingImfile $pageName chip_id -var CHIP_ID 145 147 book getword chipPendingImfile $pageName chip_imfile_id -var CHIP_IMFILE_ID … … 151 153 book getword chipPendingImfile $pageName state -var RUN_STATE 152 154 155 if ("$RAW_MAGICKED" == "T") 156 $MAGICKED_ARG = "--magicked" 157 else 158 $MAGICKED_ARG = "" 159 end 160 153 161 # specify choice of local or remote host based on camera and chip (class_id) 154 162 set.host.for.camera $CAMERA $CLASS_ID … … 171 179 stderr $LOGDIR/chip.imfile.log 172 180 173 $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --chip_imfile_id $CHIP_IMFILE_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --run-state $RUN_STATE --outroot $outroot --redirect-output181 $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --chip_imfile_id $CHIP_IMFILE_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --run-state $RUN_STATE $MAGICKED_ARG --deburned $DEBURNED --outroot $outroot --redirect-output 174 182 if ("$REDUCTION" != "NULL") 175 183 $run = $run --reduction $REDUCTION -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.norm.pro
r23352 r23594 9 9 book init detPendingNormImfile 10 10 book init detPendingNormExp 11 12 book init detCleanupNormStatImfile13 book init detCleanupNormImfile14 book init detCleanupNormExp15 11 16 12 macro detnorm.reset … … 18 14 book init detPendingNormImfile 19 15 book init detPendingNormExp 20 21 book init detCleanupNormStatImfile22 book init detCleanupNormImfile23 book init detCleanupNormExp24 16 end 25 17 … … 28 20 book listbook detPendingNormImfile 29 21 book listbook detPendingNormExp 30 31 book listbook detCleanupNormStatImfile32 book listbook detCleanupNormImfile33 book listbook detCleanupNormExp34 22 end 35 23 … … 53 41 active true 54 42 end 55 56 task detrend.cleanup.norm.load57 active true58 end59 task detrend.cleanup.norm.run60 active true61 end62 task detrend.cleanup.normexp.load63 active true64 end65 task detrend.cleanup.normexp.run66 active true67 end68 task detrend.cleanup.normstat.load69 active true70 end71 task detrend.cleanup.normstat.run72 active true73 end74 43 end 75 44 … … 91 60 end 92 61 task detrend.normstat.run 93 active false94 end95 task detrend.cleanup.norm.load96 active false97 end98 task detrend.cleanup.norm.run99 active false100 end101 task detrend.cleanup.normexp.load102 active false103 end104 task detrend.cleanup.normexp.run105 active false106 end107 task detrend.cleanup.normstat.load108 active false109 end110 task detrend.cleanup.normstat.run111 62 active false 112 63 end … … 117 68 $detPendingNormImfile_DB = 0 118 69 $detPendingNormExp_DB = 0 119 120 $detCleanupNormStatImfile_DB = 0121 $detCleanupNormImfile_DB = 0122 $detCleanupNormExp_DB = 0123 70 124 71 # select images ready for copy … … 493 440 end 494 441 end 495 496 ########## cleanup normstat ###########497 task detrend.cleanup.normstat.load498 host local499 500 periods -poll $LOADPOLL501 periods -exec $LOADEXEC502 periods -timeout 30503 npending 1504 active true505 506 stdout NULL507 stderr $LOGDIR/detrend.cleanup.normstat.log508 509 task.exec510 $run = dettool -pendingcleanup_normalizedstat511 if ($DB:n == 0)512 option DEFAULT513 else514 # save the DB name for the exit tasks515 option $DB:$detCleanupNormStatImfile_DB516 $run = $run -dbname $DB:$detCleanupNormStatImfile_DB517 $detCleanupNormStatImfile_DB ++518 if ($detCleanupNormStatImfile_DB >= $DB:n) set detCleanupNormStatImfile_DB = 0519 end520 add_poll_args run521 command $run522 end523 524 # success525 task.exit 0526 # convert 'stdout' to book format527 ipptool2book stdout detCleanupNormStatImfile -key det_id:iteration -uniq -setword dbname $options:0 -setword pantaskState INIT528 if ($VERBOSE > 2)529 book listbook detCleanupNormStatImfile530 end531 532 # delete existing entries in the appropriate pantaskStates533 process_cleanup detCleanupNormStatImfile534 end535 536 # locked list537 task.exit default538 showcommand failure539 end540 541 task.exit crash542 showcommand crash543 end544 545 # operation times out?546 task.exit timeout547 showcommand timeout548 end549 end550 551 # run the ipp_cleanup.pl script on pending images552 task detrend.cleanup.normstat.run553 periods -poll $RUNPOLL554 periods -exec $RUNEXEC555 periods -timeout 60556 active true557 558 task.exec559 book npages detCleanupNormStatImfile -var N560 if ($N == 0) break561 if ($NETWORK == 0) break562 563 # look for new images in detCleanupNormStatImfile (pantaskState == INIT)564 book getpage detCleanupNormStatImfile 0 -var pageName -key pantaskState INIT565 if ("$pageName" == "NULL") break566 567 book setword detCleanupNormStatImfile $pageName pantaskState RUN568 book getword detCleanupNormStatImfile $pageName det_id -var DET_ID569 book getword detCleanupNormStatImfile $pageName iteration -var ITERATION570 book getword detCleanupNormStatImfile $pageName camera -var CAMERA571 book getword detCleanupNormStatImfile $pageName state -var CLEANUP_MODE572 book getword detCleanupNormStatImfile $pageName dbname -var DBNAME573 574 # specify choice of local or remote host based on camera and chip (class_id)575 set.host.for.camera $CAMERA FPA576 577 stdout $LOGDIR/detrend.cleanup.normstat.log578 stderr $LOGDIR/detrend.cleanup.normstat.log579 580 # XXX is everything listed here needed?581 $run = ipp_cleanup.pl --stage detrend.normstat.imfile --stage_id $DET_ID --iteration $ITERATION --camera $CAMERA --mode $CLEANUP_MODE582 add_standard_args run583 584 # save the pageName for future reference below585 options $pageName586 587 # create the command line588 if ($VERBOSE > 1)589 echo command $run590 end591 command $run592 end593 594 # default exit status595 task.exit default596 process_exit detCleanupNormStatImfile $options:0 $JOB_STATUS597 end598 599 task.exit crash600 showcommand crash601 book setword detCleanupNormStatImfile $options:0 pantaskState CRASH602 end603 604 # operation timed out?605 task.exit timeout606 showcommand timeout607 book setword detCleanupNormStatImfile $options:0 pantaskState TIMEOUT608 end609 end610 611 ########## cleanup norm (normalized.imfile) ###########612 task detrend.cleanup.norm.load613 host local614 615 periods -poll $LOADPOLL616 periods -exec $LOADEXEC617 periods -timeout 30618 npending 1619 active true620 621 stdout NULL622 stderr $LOGDIR/detrend.cleanup.norm.log623 624 task.exec625 $run = dettool -pendingcleanup_normalizedimfile626 if ($DB:n == 0)627 option DEFAULT628 else629 # save the DB name for the exit tasks630 option $DB:$detCleanupNormImfile_DB631 $run = $run -dbname $DB:$detCleanupNormImfile_DB632 $detCleanupNormImfile_DB ++633 if ($detCleanupNormImfile_DB >= $DB:n) set detCleanupNormImfile_DB = 0634 end635 add_poll_args run636 command $run637 end638 639 # success640 task.exit 0641 # convert 'stdout' to book format642 ipptool2book stdout detCleanupNormImfile -key det_id:iteration:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT643 if ($VERBOSE > 2)644 book listbook detCleanupNormImfile645 end646 647 # delete existing entries in the appropriate pantaskStates648 process_cleanup detCleanupNormImfile649 end650 651 # locked list652 task.exit default653 showcommand failure654 end655 656 task.exit crash657 showcommand crash658 end659 660 # operation times out?661 task.exit timeout662 showcommand timeout663 end664 end665 666 # run the ipp_cleanup.pl script on pending images667 task detrend.cleanup.norm.run668 periods -poll $RUNPOLL669 periods -exec $RUNEXEC670 periods -timeout 60671 active true672 673 task.exec674 book npages detCleanupNormImfile -var N675 if ($N == 0) break676 if ($NETWORK == 0) break677 678 # look for new images in detCleanupNormImfile (pantaskState == INIT)679 book getpage detCleanupNormImfile 0 -var pageName -key pantaskState INIT680 if ("$pageName" == "NULL") break681 682 book setword detCleanupNormImfile $pageName pantaskState RUN683 book getword detCleanupNormImfile $pageName det_id -var DET_ID684 book getword detCleanupNormImfile $pageName iteration -var ITERATION685 book getword detCleanupNormImfile $pageName class_id -var CLASS_ID686 book getword detCleanupNormImfile $pageName camera -var CAMERA687 book getword detCleanupNormImfile $pageName state -var CLEANUP_MODE688 book getword detCleanupNormImfile $pageName dbname -var DBNAME689 690 # specify choice of local or remote host based on camera and chip (class_id)691 set.host.for.camera $CAMERA FPA692 693 stdout $LOGDIR/detrend.cleanup.norm.log694 stderr $LOGDIR/detrend.cleanup.norm.log695 696 # XXX is everything listed here needed?697 $run = ipp_cleanup.pl --stage detrend.norm.imfile --stage_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --camera $CAMERA --mode $CLEANUP_MODE698 add_standard_args run699 700 # save the pageName for future reference below701 options $pageName702 703 # create the command line704 if ($VERBOSE > 1)705 echo command $run706 end707 command $run708 end709 710 # default exit status711 task.exit default712 process_exit detCleanupNormImfile $options:0 $JOB_STATUS713 end714 715 task.exit crash716 showcommand crash717 book setword detCleanupNormImfile $options:0 pantaskState CRASH718 end719 720 # operation timed out?721 task.exit timeout722 showcommand timeout723 book setword detCleanupNormImfile $options:0 pantaskState TIMEOUT724 end725 end726 727 ########## cleanup normexp ###########728 task detrend.cleanup.normexp.load729 host local730 731 periods -poll $LOADPOLL732 periods -exec $LOADEXEC733 periods -timeout 30734 npending 1735 active true736 737 stdout NULL738 stderr $LOGDIR/detrend.normexp.cleanup.log739 740 task.exec741 $run = dettool -pendingcleanup_normalizedexp742 if ($DB:n == 0)743 option DEFAULT744 else745 # save the DB name for the exit tasks746 option $DB:$detCleanupNormExp_DB747 $run = $run -dbname $DB:$detCleanupNormExp_DB748 $detCleanupNormExp_DB ++749 if ($detCleanupNormExp_DB >= $DB:n) set detCleanupNormExp_DB = 0750 end751 add_poll_args run752 command $run753 end754 755 # success756 task.exit 0757 # convert 'stdout' to book format758 ipptool2book stdout detCleanupNormExp -key det_id:iteration -uniq -setword dbname $options:0 -setword pantaskState INIT759 if ($VERBOSE > 2)760 book listbook detCleanupNormExp761 end762 763 # delete existing entries in the appropriate pantaskStates764 process_cleanup detCleanupNormExp765 end766 767 # locked list768 task.exit default769 showcommand failure770 end771 772 task.exit crash773 showcommand crash774 end775 776 # operation times out?777 task.exit timeout778 showcommand timeout779 end780 end781 782 # run the ipp_cleanup.pl script on pending images783 task detrend.cleanup.normexp.run784 periods -poll $RUNPOLL785 periods -exec $RUNEXEC786 periods -timeout 60787 active true788 789 task.exec790 book npages detCleanupNormExp -var N791 if ($N == 0) break792 if ($NETWORK == 0) break793 794 # look for new images in detCleanupNormExp (pantaskState == INIT)795 book getpage detCleanupNormExp 0 -var pageName -key pantaskState INIT796 if ("$pageName" == "NULL") break797 798 book setword detCleanupNormExp $pageName pantaskState RUN799 book getword detCleanupNormExp $pageName det_id -var DET_ID800 book getword detCleanupNormExp $pageName iteration -var ITERATION801 book getword detCleanupNormExp $pageName camera -var CAMERA802 book getword detCleanupNormExp $pageName state -var CLEANUP_MODE803 book getword detCleanupNormExp $pageName dbname -var DBNAME804 805 # specify choice of local or remote host based on camera and chip (class_id)806 set.host.for.camera $CAMERA FPA807 808 stdout $LOGDIR/detrend.cleanup.normexp.log809 stderr $LOGDIR/detrend.cleanup.normexp.log810 811 # XXX is everything listed here needed?812 $run = ipp_cleanup.pl --stage detrend.norm.exp --stage_id $DET_ID --iteration $ITERATION --camera $CAMERA --mode $CLEANUP_MODE813 add_standard_args run814 815 # save the pageName for future reference below816 options $pageName817 818 # create the command line819 if ($VERBOSE > 1)820 echo command $run821 end822 command $run823 end824 825 # default exit status826 task.exit default827 process_exit detCleanupNormExp $options:0 $JOB_STATUS828 end829 830 task.exit crash831 showcommand crash832 book setword detCleanupNormExp $options:0 pantaskState CRASH833 end834 835 # operation timed out?836 task.exit timeout837 showcommand timeout838 book setword detCleanupNormExp $options:0 pantaskState TIMEOUT839 end840 end841 -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.process.pro
r23352 r23594 8 8 book init detPendingProcessedImfile 9 9 book init detPendingProcessedExp 10 book init detCleanupProcessedImfile11 book init detCleanupProcessedExp12 10 13 11 macro detproc.reset 14 12 book init detPendingProcessedImfile 15 13 book init detPendingProcessedExp 16 book init detCleanupProcessedImfile17 book init detCleanupProcessedExp18 14 end 19 15 … … 23 19 echo detPendingProcessedExp 24 20 book listbook detPendingProcessedExp 25 echo detCleanupProcessedImfile26 book listbook detCleanupProcessedImfile27 echo detCleanupProcessedExp28 book listbook detCleanupProcessedExp29 21 end 30 22 … … 42 34 active true 43 35 end 44 task detrend.cleanup.process.load45 active true46 end47 task detrend.cleanup.process.run48 active true49 end50 task detrend.cleanup.processexp.load51 active true52 end53 task detrend.cleanup.processexp.run54 active true55 end56 36 end 57 37 … … 69 49 active false 70 50 end 71 task detrend.cleanup.process.load72 active false73 end74 task detrend.cleanup.process.run75 active false76 end77 task detrend.cleanup.processexp.load78 active false79 end80 task detrend.cleanup.processexp.run81 active false82 end83 51 end 84 52 … … 87 55 $detPendingProcessedImfile_DB = 0 88 56 $detPendingProcessedExp_DB = 0 89 $detCleanupProcessedImfile_DB = 090 $detCleanupProcessedExp_DB = 091 57 92 58 # select images ready for copy … … 347 313 end 348 314 end 349 350 ######## cleanup process imfile ########351 task detrend.cleanup.process.load352 host local353 354 periods -poll $LOADPOLL355 periods -exec $LOADEXEC356 periods -timeout 30357 npending 1358 active true359 360 stdout NULL361 stderr $LOGDIR/detrend.cleanup.process.imfile.log362 363 task.exec364 $run = dettool -pendingcleanup_processedimfile365 if ($DB:n == 0)366 option DEFAULT367 else368 # save the DB name for the exit tasks369 option $DB:$detCleanupProcessedImfile_DB370 $run = $run -dbname $DB:$detCleanupProcessedImfile_DB371 $detCleanupProcessedImfile_DB ++372 if ($detCleanupProcessedImfile_DB >= $DB:n) set detCleanupProcessedImfile_DB = 0373 end374 add_poll_args run375 command $run376 end377 378 # success379 task.exit 0380 # convert 'stdout' to book format381 ipptool2book stdout detCleanupProcessedImfile -key det_id:exp_id:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT382 if ($VERBOSE > 2)383 book listbook detCleanupProcessedImfile384 end385 386 # delete existing entries in the appropriate pantaskStates387 process_cleanup detCleanupProcessedImfile388 end389 390 # locked list391 task.exit default392 showcommand failure393 end394 395 task.exit crash396 showcommand crash397 end398 399 # operation times out?400 task.exit timeout401 showcommand timeout402 end403 end404 405 # run the ipp_cleanup.pl script on pending images406 task detrend.cleanup.process.run407 periods -poll $RUNPOLL408 periods -exec $RUNEXEC409 periods -timeout 60410 active true411 412 task.exec413 book npages detCleanupProcessedImfile -var N414 if ($N == 0) break415 if ($NETWORK == 0) break416 417 # look for new images in detCleanupProcessedImfile (pantaskState == INIT)418 book getpage detCleanupProcessedImfile 0 -var pageName -key pantaskState INIT419 if ("$pageName" == "NULL") break420 421 book setword detCleanupProcessedImfile $pageName pantaskState RUN422 book getword detCleanupProcessedImfile $pageName det_id -var DET_ID423 book getword detCleanupProcessedImfile $pageName exp_id -var EXP_ID424 book getword detCleanupProcessedImfile $pageName class_id -var CLASS_ID425 book getword detCleanupProcessedImfile $pageName camera -var CAMERA426 book getword detCleanupProcessedImfile $pageName state -var CLEANUP_MODE427 book getword detCleanupProcessedImfile $pageName dbname -var DBNAME428 429 # specify choice of local or remote host based on camera and chip (class_id)430 set.host.for.camera $CAMERA FPA431 432 stdout $LOGDIR/detrend.cleanup.process.imfile.log433 stderr $LOGDIR/detrend.cleanup.process.imfile.log434 435 # XXX is everything listed here needed?436 $run = ipp_cleanup.pl --stage detrend.process.imfile --stage_id $DET_ID --exp_id $EXP_ID --class_id $CLASS_ID --camera $CAMERA --mode $CLEANUP_MODE437 add_standard_args run438 439 # save the pageName for future reference below440 options $pageName441 442 # create the command line443 if ($VERBOSE > 1)444 echo command $run445 end446 command $run447 end448 449 # default exit status450 task.exit default451 process_exit detCleanupProcessedImfile $options:0 $JOB_STATUS452 end453 454 # locked list455 task.exit crash456 showcommand crash457 echo "hostname: $JOB_HOSTNAME"458 book setword detCleanupProcessedImfile $options:0 pantaskState CRASH459 end460 461 # operation timed out?462 task.exit timeout463 showcommand timeout464 book setword detCleanupProcessedImfile $options:0 pantaskState TIMEOUT465 end466 end467 468 469 ######## cleanup process exp ########470 task detrend.cleanup.processexp.load471 host local472 473 periods -poll $LOADPOLL474 periods -exec $LOADEXEC475 periods -timeout 30476 npending 1477 active true478 479 stdout NULL480 stderr $LOGDIR/detrend.cleanup.process.exp.log481 482 task.exec483 $run = dettool -pendingcleanup_processedexp484 if ($DB:n == 0)485 option DEFAULT486 else487 # save the DB name for the exit tasks488 option $DB:$detCleanupProcessedExp_DB489 $run = $run -dbname $DB:$detCleanupProcessedExp_DB490 $detCleanupProcessedExp_DB ++491 if ($detCleanupProcessedExp_DB >= $DB:n) set detCleanupProcessedExp_DB = 0492 end493 add_poll_args run494 command $run495 end496 497 # success498 task.exit 0499 # convert 'stdout' to book format500 ipptool2book stdout detCleanupProcessedExp -key det_id:exp_id -uniq -setword dbname $options:0 -setword pantaskState INIT501 if ($VERBOSE > 2)502 book listbook detCleanupProcessedExp503 end504 505 # delete existing entries in the appropriate pantaskStates506 process_cleanup detCleanupProcessedExp507 end508 509 # locked list510 task.exit default511 showcommand failure512 end513 514 task.exit crash515 showcommand crash516 end517 518 # operation times out?519 task.exit timeout520 showcommand timeout521 end522 end523 524 # run the ipp_cleanup.pl script on pending images525 task detrend.cleanup.processexp.run526 periods -poll $RUNPOLL527 periods -exec $RUNEXEC528 periods -timeout 60529 active true530 531 task.exec532 book npages detCleanupProcessedExp -var N533 if ($N == 0) break534 if ($NETWORK == 0) break535 536 # look for new images in detCleanupProcessedExp (pantaskState == INIT)537 book getpage detCleanupProcessedExp 0 -var pageName -key pantaskState INIT538 if ("$pageName" == "NULL") break539 540 book setword detCleanupProcessedExp $pageName pantaskState RUN541 book getword detCleanupProcessedExp $pageName det_id -var DET_ID542 book getword detCleanupProcessedExp $pageName exp_id -var EXP_ID543 book getword detCleanupProcessedExp $pageName camera -var CAMERA544 book getword detCleanupProcessedExp $pageName state -var CLEANUP_MODE545 book getword detCleanupProcessedExp $pageName dbname -var DBNAME546 547 # specify choice of local or remote host based on camera and chip (class_id)548 set.host.for.camera $CAMERA FPA549 550 stdout $LOGDIR/detrend.cleanup.process.exp.log551 stderr $LOGDIR/detrend.cleanup.process.exp.log552 553 # XXX is everything listed here needed?554 $run = ipp_cleanup.pl --stage detrend.process.exp --stage_id $DET_ID --exp_id $EXP_ID --camera $CAMERA --mode $CLEANUP_MODE555 add_standard_args run556 557 # save the pageName for future reference below558 options $pageName559 560 # create the command line561 if ($VERBOSE > 1)562 echo command $run563 end564 command $run565 end566 567 # default exit status568 task.exit default569 process_exit detCleanupProcessedExp $options:0 $JOB_STATUS570 end571 572 # locked list573 task.exit crash574 showcommand crash575 echo "hostname: $JOB_HOSTNAME"576 book setword detCleanupProcessedExp $options:0 pantaskState CRASH577 end578 579 # operation timed out?580 task.exit timeout581 showcommand timeout582 book setword detCleanupProcessedExp $options:0 pantaskState TIMEOUT583 end584 end -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.resid.pro
r23352 r23594 8 8 book init detPendingResidImfile 9 9 book init detPendingResidExp 10 book init detCleanupResidImfile11 book init detCleanupResidExp12 10 13 11 macro detresid.reset 14 12 book init detPendingResidImfile 15 13 book init detPendingResidExp 16 book init detCleanupResidImfile17 book init detCleanupResidExp18 14 end 19 15 … … 21 17 book listbook detPendingResidImfile 22 18 book listbook detPendingResidExp 23 book listbook detCleanupResidImfile24 book listbook detCleanupResidExp25 19 end 26 20 … … 38 32 active true 39 33 end 40 task detrend.cleanup.resid.load41 active true42 end43 task detrend.cleanup.resid.run44 active true45 end46 task detrend.cleanup.residexp.load47 active true48 end49 task detrend.cleanup.residexp.run50 active true51 end52 34 end 53 35 … … 65 47 active false 66 48 end 67 task detrend.cleanup.resid.load68 active false69 end70 task detrend.cleanup.resid.run71 active false72 end73 task detrend.cleanup.residexp.load74 active false75 end76 task detrend.cleanup.residexp.run77 active false78 end79 49 end 80 50 … … 82 52 $detPendingResidImfile_DB = 0 83 53 $detPendingResidExp_DB = 0 84 $detCleanupResidImfile_DB = 085 $detCleanupResidExp_DB = 086 54 87 55 # select images ready for copy … … 348 316 end 349 317 end 350 351 ######## cleanup resid imfile ########352 task detrend.cleanup.resid.load353 host local354 355 periods -poll $LOADPOLL356 periods -exec $LOADEXEC357 periods -timeout 30358 npending 1359 active true360 361 stdout NULL362 stderr $LOGDIR/detrend.cleanup.resid.imfile.log363 364 task.exec365 $run = dettool -pendingcleanup_residimfile366 if ($DB:n == 0)367 option DEFAULT368 else369 # save the DB name for the exit tasks370 option $DB:$detCleanupResidImfile_DB371 $run = $run -dbname $DB:$detCleanupResidImfile_DB372 $detCleanupResidImfile_DB ++373 if ($detCleanupResidImfile_DB >= $DB:n) set detCleanupResidImfile_DB = 0374 end375 add_poll_args run376 command $run377 end378 379 # success380 task.exit 0381 # convert 'stdout' to book format382 ipptool2book stdout detCleanupResidImfile -key det_id:iteration:exp_id:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT383 if ($VERBOSE > 2)384 book listbook detCleanupResidImfile385 end386 387 # delete existing entries in the appropriate pantaskStates388 process_cleanup detCleanupResidImfile389 end390 391 # locked list392 task.exit default393 showcommand failure394 end395 396 task.exit crash397 showcommand crash398 end399 400 # operation times out?401 task.exit timeout402 showcommand timeout403 end404 end405 406 # run the ipp_cleanup.pl script on pending images407 task detrend.cleanup.resid.run408 periods -poll $RUNPOLL409 periods -exec $RUNEXEC410 periods -timeout 60411 active true412 413 task.exec414 book npages detCleanupResidImfile -var N415 if ($N == 0) break416 if ($NETWORK == 0) break417 418 # look for new images in detCleanupResidImfile (pantaskState == INIT)419 book getpage detCleanupResidImfile 0 -var pageName -key pantaskState INIT420 if ("$pageName" == "NULL") break421 422 book setword detCleanupResidImfile $pageName pantaskState RUN423 book getword detCleanupResidImfile $pageName det_id -var DET_ID424 book getword detCleanupResidImfile $pageName exp_id -var EXP_ID425 book getword detCleanupResidImfile $pageName class_id -var CLASS_ID426 book getword detCleanupResidImfile $pageName iteration -var ITERATION427 book getword detCleanupResidImfile $pageName camera -var CAMERA428 book getword detCleanupResidImfile $pageName state -var CLEANUP_MODE429 book getword detCleanupResidImfile $pageName dbname -var DBNAME430 431 # specify choice of local or remote host based on camera and chip (class_id)432 set.host.for.camera $CAMERA FPA433 434 stdout $LOGDIR/detrend.cleanup.resid.imfile.log435 stderr $LOGDIR/detrend.cleanup.resid.imfile.log436 437 # XXX is everything listed here needed?438 $run = ipp_cleanup.pl --stage detrend.resid.imfile --stage_id $DET_ID --exp_id $EXP_ID --class_id $CLASS_ID --iteration $ITERATION --camera $CAMERA --mode $CLEANUP_MODE439 add_standard_args run440 441 # save the pageName for future reference below442 options $pageName443 444 # create the command line445 if ($VERBOSE > 1)446 echo command $run447 end448 command $run449 end450 451 # default exit status452 task.exit default453 process_exit detCleanupResidImfile $options:0 $JOB_STATUS454 end455 456 # locked list457 task.exit crash458 showcommand crash459 echo "hostname: $JOB_HOSTNAME"460 book setword detCleanupResidImfile $options:0 pantaskState CRASH461 end462 463 # operation timed out?464 task.exit timeout465 showcommand timeout466 book setword detCleanupResidImfile $options:0 pantaskState TIMEOUT467 end468 end469 470 471 ######## cleanup resid exp ########472 task detrend.cleanup.residexp.load473 host local474 475 periods -poll $LOADPOLL476 periods -exec $LOADEXEC477 periods -timeout 30478 npending 1479 active true480 481 stdout NULL482 stderr $LOGDIR/detrend.cleanup.resid.exp.log483 484 task.exec485 $run = dettool -pendingcleanup_residexp486 if ($DB:n == 0)487 option DEFAULT488 else489 # save the DB name for the exit tasks490 option $DB:$detCleanupResidExp_DB491 $run = $run -dbname $DB:$detCleanupResidExp_DB492 $detCleanupResidExp_DB ++493 if ($detCleanupResidExp_DB >= $DB:n) set detCleanupResidExp_DB = 0494 end495 add_poll_args run496 command $run497 end498 499 # success500 task.exit 0501 # convert 'stdout' to book format502 ipptool2book stdout detCleanupResidExp -key det_id:iteration:exp_id -uniq -setword dbname $options:0 -setword pantaskState INIT503 if ($VERBOSE > 2)504 book listbook detCleanupResidExp505 end506 507 # delete existing entries in the appropriate pantaskStates508 process_cleanup detCleanupResidExp509 end510 511 # locked list512 task.exit default513 showcommand failure514 end515 516 task.exit crash517 showcommand crash518 end519 520 # operation times out?521 task.exit timeout522 showcommand timeout523 end524 end525 526 # run the ipp_cleanup.pl script on pending images527 task detrend.cleanup.residexp.run528 periods -poll $RUNPOLL529 periods -exec $RUNEXEC530 periods -timeout 60531 active true532 533 task.exec534 book npages detCleanupResidExp -var N535 if ($N == 0) break536 if ($NETWORK == 0) break537 538 # look for new images in detCleanupResidExp (pantaskState == INIT)539 book getpage detCleanupResidExp 0 -var pageName -key pantaskState INIT540 if ("$pageName" == "NULL") break541 542 book setword detCleanupResidExp $pageName pantaskState RUN543 book getword detCleanupResidExp $pageName det_id -var DET_ID544 book getword detCleanupResidExp $pageName exp_id -var EXP_ID545 book getword detCleanupResidExp $pageName iteration -var ITERATION546 book getword detCleanupResidExp $pageName camera -var CAMERA547 book getword detCleanupResidExp $pageName state -var CLEANUP_MODE548 book getword detCleanupResidExp $pageName dbname -var DBNAME549 550 # specify choice of local or remote host based on camera and chip (class_id)551 set.host.for.camera $CAMERA FPA552 553 stdout $LOGDIR/detrend.cleanup.resid.exp.log554 stderr $LOGDIR/detrend.cleanup.resid.exp.log555 556 # XXX is everything listed here needed?557 $run = ipp_cleanup.pl --stage detrend.resid.exp --stage_id $DET_ID --exp_id $EXP_ID --class_id $CLASS_ID --camera $CAMERA --mode $CLEANUP_MODE558 add_standard_args run559 560 # save the pageName for future reference below561 options $pageName562 563 # create the command line564 if ($VERBOSE > 1)565 echo command $run566 end567 command $run568 end569 570 # default exit status571 task.exit default572 process_exit detCleanupResidExp $options:0 $JOB_STATUS573 end574 575 # locked list576 task.exit crash577 showcommand crash578 echo "hostname: $JOB_HOSTNAME"579 book setword detCleanupResidExp $options:0 pantaskState CRASH580 end581 582 # operation timed out?583 task.exit timeout584 showcommand timeout585 book setword detCleanupResidExp $options:0 pantaskState TIMEOUT586 end587 end -
branches/cnb_branches/cnb_branch_20090301/ippTasks/detrend.stack.pro
r23352 r23594 7 7 8 8 book init detPendingStackedImfile 9 book init detCleanupStackedImfile10 9 11 10 macro detstack.reset 12 11 book init detPendingStackedImfile 13 book init detCleanupStackedImfile14 12 end 15 13 … … 17 15 echo detPendingStackedImfile 18 16 book listbook detPendingStackedImfile 19 echo detCleanupStackedImfile20 book listbook detCleanupStackedImfile21 17 end 22 18 … … 26 22 end 27 23 task detrend.stack.run 28 active true29 end30 task detrend.cleanup.stack.load31 active true32 end33 task detrend.cleanup.stack.run34 24 active true 35 25 end … … 43 33 active false 44 34 end 45 task detrend.cleanup.stack.load46 active false47 end48 task detrend.cleanup.stack.run49 active false50 end51 35 end 52 36 53 37 # this variable will cycle through the known database names 54 38 $detPendingStackedImfile_DB = 0 55 $detCleanupStackedImfile_DB = 056 39 57 40 # select images ready for detrend_stack.pl … … 182 165 end 183 166 end 184 185 ########## cleanup stack ###########186 task detrend.cleanup.stack.load187 host local188 189 periods -poll $LOADPOLL190 periods -exec $LOADEXEC191 periods -timeout 30192 npending 1193 active true194 195 stdout NULL196 stderr $LOGDIR/detrend.cleanup.stack.log197 198 task.exec199 $run = dettool -pendingcleanup_stacked200 if ($DB:n == 0)201 option DEFAULT202 else203 # save the DB name for the exit tasks204 option $DB:$detCleanupStackedImfile_DB205 $run = $run -dbname $DB:$detCleanupStackedImfile_DB206 $detCleanupStackedImfile_DB ++207 if ($detCleanupStackedImfile_DB >= $DB:n) set detCleanupStackedImfile_DB = 0208 end209 add_poll_args run210 command $run211 end212 213 # success214 task.exit 0215 # convert 'stdout' to book format216 ipptool2book stdout detCleanupStackedImfile -key det_id:iteration:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT217 if ($VERBOSE > 2)218 book listbook detCleanupStackedImfile219 end220 221 # delete existing entries in the appropriate pantaskStates222 process_cleanup detCleanupStackedImfile223 end224 225 # locked list226 task.exit default227 showcommand failure228 end229 230 task.exit crash231 showcommand crash232 end233 234 # operation times out?235 task.exit timeout236 showcommand timeout237 end238 end239 240 # run the ipp_cleanup.pl script on pending images241 task detrend.cleanup.stack.run242 periods -poll $RUNPOLL243 periods -exec $RUNEXEC244 periods -timeout 60245 active true246 247 task.exec248 book npages detCleanupStackedImfile -var N249 if ($N == 0) break250 if ($NETWORK == 0) break251 252 # look for new images in detCleanupStackedImfile (pantaskState == INIT)253 book getpage detCleanupStackedImfile 0 -var pageName -key pantaskState INIT254 if ("$pageName" == "NULL") break255 256 book setword detCleanupStackedImfile $pageName pantaskState RUN257 book getword detCleanupStackedImfile $pageName det_id -var DET_ID258 book getword detCleanupStackedImfile $pageName iteration -var ITERATION259 book getword detCleanupStackedImfile $pageName class_id -var CLASS_ID260 book getword detCleanupStackedImfile $pageName camera -var CAMERA261 book getword detCleanupStackedImfile $pageName state -var CLEANUP_MODE262 book getword detCleanupStackedImfile $pageName dbname -var DBNAME263 264 # specify choice of local or remote host based on camera and chip (class_id)265 set.host.for.camera $CAMERA FPA266 267 stdout $LOGDIR/detrend.cleanup.stack.log268 stderr $LOGDIR/detrend.cleanup.stack.log269 270 # XXX is everything listed here needed?271 $run = ipp_cleanup.pl --stage detrend.stack.imfile --stage_id $DET_ID --iteration $ITERATION --class_id $CLASS_ID --camera $CAMERA --mode $CLEANUP_MODE272 add_standard_args run273 274 # save the pageName for future reference below275 options $pageName276 277 # create the command line278 if ($VERBOSE > 1)279 echo command $run280 end281 command $run282 end283 284 # default exit status285 task.exit default286 process_exit detCleanupStackedImfile $options:0 $JOB_STATUS287 end288 289 # locked list290 task.exit crash291 showcommand crash292 echo "hostname: $JOB_HOSTNAME"293 book setword detCleanupStackedImfile $options:0 pantaskState CRASH294 end295 296 # operation timed out?297 task.exit timeout298 showcommand timeout299 book setword detCleanupStackedImfile $options:0 pantaskState TIMEOUT300 end301 end302 -
branches/cnb_branches/cnb_branch_20090301/ippTasks/dist.pro
r23352 r23594 134 134 book getword distToProcess $pageName outroot -var OUTROOT 135 135 book getword distToProcess $pageName dbname -var DBNAME 136 if ("$CLEAN" = "T") 137 $CLEAN_ARG = "--clean" 138 else 139 $CLEAN_ARG = "" 140 end 141 # magicked is output as integer due to the union in the sql 142 if ($MAGICKED) 143 $MAGICKED_ARG = "--magicked" 144 else 145 $MAGICKED_ARG = "" 146 end 136 147 137 148 # set.host.for.camera $CAMERA $MAGIC_ID … … 141 152 sprintf logfile "%s/dist.%s.%s.log" $OUTROOT $DIST_ID $COMPONENT 142 153 143 $run = dist_component.pl --dist_id $DIST_ID --camera $CAMERA --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --path_base $PATH_BASE --chip_path_base $CHIP_PATH_BASE --state $STATE --data_state $DATA_STATE --magicked $MAGICKED --clean $CLEAN--outroot $OUTROOT --logfile $logfile154 $run = dist_component.pl --dist_id $DIST_ID --camera $CAMERA --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --path_base $PATH_BASE --chip_path_base $CHIP_PATH_BASE --state $STATE --data_state $DATA_STATE $MAGICKED_ARG $CLEAN_ARG --outroot $OUTROOT --logfile $logfile 144 155 145 156 add_standard_args run -
branches/cnb_branches/cnb_branch_20090301/ippTasks/nebulous.site.pro.in
r19748 r23594 1 1 # customize these variables for your site 2 # and copy the file to share/pantasks/modules directory in your installation 2 3 3 $NEB_DB = nebulous4 $NEB_HOST = alala4 $NEB_DB = your_nebulous_database_name 5 $NEB_HOST = host_for_nebulous_mysql_database 5 6 $NEB_USER = XXX 6 7 $NEB_PASS = XXX -
branches/cnb_branches/cnb_branch_20090301/ippTasks/pantasks.pro
r22422 r23594 13 13 $KEEP_FAILURES = 0 14 14 15 $LOADPOLL = 0.2515 $LOADPOLL = 1.0 16 16 $LOADEXEC = 5 17 17 $RUNPOLL = 0.5 -
branches/cnb_branches/cnb_branch_20090301/ippTasks/replicate.pro
r23352 r23594 74 74 75 75 # modify these after the tasks are tested 76 periods -poll 1077 periods -exec 1076 periods -poll 0.5 77 periods -exec 5 78 78 periods -timeout 1500 79 79 npending 1 … … 84 84 85 85 task.exec 86 book npages replicatePending -var N 87 if ($N > 2000) 88 process_cleanup replicatePending 89 break 90 end 91 86 92 # command does not need to be dynamic, but having it so allows us to adjust the periods 87 93 # so that we dont have to wait 10 minutes for things to start up 88 94 # 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 90 periods -exec 1800 91 92 end 93 94 # success 95 task.exit $EXIT_SUCCESS 95 command neb-admin --host $NEB_HOST --db $NEB_DB --user $NEB_USER --pass $NEB_PASS --pendingreplicate --limit 500 --so_id_start $SO_ID_START --so_id_range $SO_ID_RANGE 96 # periods -exec 1800 97 end 98 99 # success : 0 -- we did not hit the limit, advance so_id counter 100 task.exit 0 96 101 # advance the so_id counter 97 $SO_ID_START += $SO_ID_RANGE 98 102 $SO_ID_START = $SO_ID_START + $SO_ID_RANGE 103 104 # convert 'stdout' to book format 105 ipptool2book stdout replicatePending -key key -uniq -setword pantaskState INIT 106 107 if ($VERBOSE > 2) 108 book listbook replicatePending 109 end 110 111 # delete existing entries in the appropriate pantaskStates 112 process_cleanup replicatePending 113 end 114 115 # success : 1 -- we DID hit the limit, do NOT advance so_id counter 116 task.exit 1 99 117 # convert 'stdout' to book format 100 118 ipptool2book stdout replicatePending -key key -uniq -setword pantaskState INIT … … 131 149 # create the desired replicas 132 150 task replicate.run 133 periods -poll $RUNPOLL134 periods -exec 30151 periods -poll 0.5 152 periods -exec 5 135 153 periods -timeout 30 136 154 … … 139 157 if ($NETWORK == 0) break 140 158 if ($N == 0) 141 periods -exec 30159 periods -exec 5 142 160 break 143 161 end -
branches/cnb_branches/cnb_branch_20090301/ippTasks/simtest.pro
r21049 r23594 45 45 echo " simtest.setup.detverify : run detrend creation and detrend verification" 46 46 echo " simtest.setup.flatcorr : run a flat-field correction demonstration" 47 echo " simtest.setup.ctemask : run a ctemask demonstration" 47 48 break 48 49 end … … 126 127 end 127 128 129 macro simtest.setup.ctemask 130 $PPSIM_RECIPE = BADCTE.TEST 131 $SIMTEST_SEQUENCE = simtest.ctemask.config 132 $SIMTEST_AUTO = simtest.ctemask.auto 133 end 134 128 135 macro simtest.setup.flatcorr 129 136 $PPSIM_RECIPE = FLATCORR -
branches/cnb_branches/cnb_branch_20090301/ippTasks/summit.copy.pro
r23352 r23594 27 27 # list of summit imfiles that need to be downloaded 28 28 book init pzPendingImfile 29 # list of pzDownloadExps that have completed downloading 30 book init pzPendingAdvance 29 31 30 32 macro copy.on … … 50 52 active true 51 53 end 54 task summit.toadvance 55 active true 56 end 52 57 task summit.advance 53 58 active true … … 75 80 end 76 81 task pztool.clearfault 82 active false 83 end 84 task summit.toadvance 77 85 active false 78 86 end … … 86 94 $pztoolPendingExp_DB = 0 87 95 $pztoolPendingImfile_DB = 0 96 $pztoolPendingAdvance_DB = 0 88 97 $pztoolClearFault_DB = 0 89 98 $pztoolAdvance_DB = 0; … … 433 442 stderr $LOGDIR/summit.copy.log 434 443 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 2444 $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 --dbname $DBNAME --timeout 120 --verbose --copies 2 436 445 if ($COMPRESS) 437 446 $run = $run --compress … … 510 519 end 511 520 512 # promote exposures for which all imfiles have been copied 513 task summit.advance 514 host local 515 516 periods -poll $LOADPOLL 517 periods -exec $LOADEXEC 518 periods -timeout 30 519 npending 1 520 521 stdout NULL 522 stderr $LOGDIR/summit.advance.log 523 524 task.exec 525 $run = pztool -advance 526 if ($DB:n == 0) 527 option DEFAULT 528 else 529 # save the DB name for the exit tasks 530 option $DB:$pztoolAdvance_DB 531 $run = $run -dbname $DB:$pztoolAdvance_DB 532 $pztoolAdvance_DB ++ 533 if ($pztoolAdvance_DB >= $DB:n) set pztoolAdvance_DB = 0 534 end 535 add_poll_args run 536 command $run 537 end 538 539 # success 540 task.exit 0 541 end 542 543 # locked list 544 task.exit default 545 showcommand failure 546 end 547 548 task.exit crash 549 showcommand crash 550 end 551 552 # operation times out? 553 task.exit timeout 554 showcommand timeout 555 end 556 end 557 521 # build a book of exposures that have completed downloading 522 task summit.toadvance 523 host local 524 525 periods -exec 30 526 periods -poll 1 527 periods -timeout 120 528 # trage 16:00 23:59 529 # trage 00:00 04:00 530 npending 1 531 532 # select entries from the current DB; cycle to the next DB, if it exists 533 # iff the DB list is not set, use the value defined in .ipprc 534 task.exec 535 if ($DB:n == 0) 536 option DEFAULT 537 command pztool -toadvance -limit 40 538 else 539 # save the DB name for the exit tasks 540 option $DB:$pztoolPendingAdvance_DB 541 command pztool -toadvance -limit 60 -dbname $DB:$pztoolPendingAdvance_DB 542 $pztoolPendingAdvance_DB ++ 543 if ($pztoolPendingAdvance_DB >= $DB:n) set pztoolPendingAdvance_DB = 0 544 end 545 end 546 547 # success 548 task.exit 0 549 # convert 'stdout' to book format 550 ipptool2book stdout pzPendingAdvance -key exp_name:camera:telescope -uniq -setword dbname $options:0 -setword pantaskState INIT 551 book shuffle pzPendingAdvance 552 553 # delete existing entries in the appropriate pantaskStates 554 process_cleanup pzPendingAdvance 555 end 556 557 task.exit default 558 showcommand failure 559 end 560 task.exit crash 561 showcommand crash 562 end 563 task.exit timeout 564 showcommand timeout 565 end 566 end 567 568 task summit.advance 569 periods -exec 5 570 periods -poll 0.05 571 periods -timeout 650 572 # trage 16:00 23:59 573 # trage 00:00 04:00 574 575 task.exec 576 if ($NETWORK == 0) break 577 578 # if we are waiting on data, make the interval long 579 book npages pzPendingAdvance -var N 580 if ($N == 0) 581 periods -exec 20 582 break 583 end 584 periods -exec 0.05 585 586 # find an exp that needs imfiles fetched 587 book getpage pzPendingAdvance 0 -var pageName -key pantaskState INIT 588 if ("$pageName" == "NULL") break 589 590 # set that exp to run 591 book setword pzPendingAdvance $pageName pantaskState RUN 592 593 book getword pzPendingAdvance $pageName exp_name -var EXP_NAME 594 book getword pzPendingAdvance $pageName camera -var CAMERA 595 book getword pzPendingAdvance $pageName telescope -var TELESCOPE 596 book getword pzPendingAdvance $pageName dbname -var DBNAME 597 598 # 2007-08-30T05:09:59Z 599 substr $DATEOBS 0 4 YEAR 600 substr $DATEOBS 5 2 MONTH 601 substr $DATEOBS 8 2 DAY 602 603 # we need to set the workdir based on 1) nebulous or not? 2) chip/host relationship 604 # this function uses workdir_template, default_host, volume_template, volume_default, 605 # it sets workdir and volume 606 set.workdir.by.camera $CAMERA $CLASS_ID $workdir_template $default_host workdir_base 607 608 $workdir = $workdir_template/$CAMERA/$YEAR\$MONTH\$DAY 609 610 # workdir examples: 611 # file://data/@HOST@.0/gpc1/20080130 612 # neb://@HOST@.0/gpc1/20080130 613 614 stdout $LOGDIR/summit.advance.log 615 stderr $LOGDIR/summit.advance.log 616 617 $run = pztool -advance -exp_name $EXP_NAME -inst $CAMERA -telescope $TELESCOPE -end_stage reg -workdir $workdir -dbname $DBNAME 618 619 # store the pageName for future reference below 620 options $pageName 621 622 # create the command line 623 if ($VERBOSE > 1) 624 echo command $run 625 end 626 command $run 627 end 628 629 # default exit status 630 task.exit default 631 process_exit pzPendingAdvance $options:0 $JOB_STATUS 632 end 633 634 task.exit crash 635 showcommand crash 636 book setword pzPendingAdvance $options:0 pantaskState CRASH 637 end 638 639 # operation timed out? 640 task.exit timeout 641 showcommand timeout 642 book setword pzPendingAdvance $options:0 pantaskState TIMEOUT 643 end 644 end -
branches/cnb_branches/cnb_branch_20090301/ippTasks/warp.pro
r23352 r23594 289 289 book getword warpPendingSkyCell $pageName exp_tag -var EXP_TAG 290 290 book getword warpPendingSkyCell $pageName state -var RUN_STATE 291 book getword warpPendingSkyCell $pageName magicked -var CHIP_MAGICKED 292 if ("$CHIP_MAGICKED" == "T") 293 $MAGICKED_ARG = "--magicked" 294 else 295 $MAGICKED_ARG = "" 296 end 297 291 298 292 299 # set the host and workdir based on the skycell hash … … 300 307 stderr $LOGDIR/warp.skycell.log 301 308 302 $run = warp_skycell.pl --threads @MAX_THREADS@ --warp_id $WARP_ID --warp_skyfile_id $WARP_SKYFILE_ID --skycell_id $SKYCELL_ID --tess_dir $TESS_DIR --camera $CAMERA --outroot $outroot --redirect-output --run-state $RUN_STATE 309 $run = warp_skycell.pl --threads @MAX_THREADS@ --warp_id $WARP_ID --warp_skyfile_id $WARP_SKYFILE_ID --skycell_id $SKYCELL_ID --tess_dir $TESS_DIR --camera $CAMERA --outroot $outroot --redirect-output --run-state $RUN_STATE $MAGICKED_ARG 303 310 add_standard_args run 304 311 -
branches/cnb_branches/cnb_branch_20090301/ippTools/configure.ac
r21308 r23594 18 18 PKG_CHECK_MODULES([PSLIB], [pslib >= 1.1.0]) 19 19 PKG_CHECK_MODULES([PSMODULES], [psmodules >= 1.1.0]) 20 PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1. 48])20 PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.50]) 21 21 22 22 PXTOOLS_CFLAGS="${PSLIB_CFLAGS=} ${PSMODULES_CFLAGS=} ${IPPDB_CFLAGS=}" -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/Makefile.am
r23352 r23594 76 76 difftool_definebyquery_part2.sql \ 77 77 difftool_definebyquery_temp_create.sql \ 78 difftool_definewarpwarp_select.sql \ 79 difftool_definewarpwarp_insert.sql \ 78 80 difftool_donecleanup.sql \ 79 81 difftool_inputskyfile.sql \ … … 152 154 regtool_revertprocessedexp.sql \ 153 155 regtool_revertprocessedimfile.sql \ 156 regtool_updateprocessedimfile.sql \ 154 157 stacktool_definebyquery_insert.sql \ 155 158 stacktool_definebyquery_insert_random_part1.sql \ … … 172 175 warptool_donecleanup.sql \ 173 176 warptool_exp.sql \ 177 warptool_finished_run_select.sql \ 178 warptool_finish_run.sql \ 174 179 warptool_imfile.sql \ 175 180 warptool_pendingcleanuprun.sql \ -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/camtool_find_processedexp.sql
r21443 r23594 1 1 SELECT DISTINCT 2 2 camProcessedExp.*, 3 chipRun.chip_id, 3 4 rawExp.exp_tag, 4 5 rawExp.exp_name, -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_change_imfile_data_state.sql
r23352 r23594 1 1 -- handle changes in data_state. Used for the modes tocleanedimfile and topurgedimfile 2 -- args are new data_state, chip_id, class_id, and current expected state for chipRun 2 -- args are new data_state, a possibly empty string for updating the magicked state, 3 -- chip_id and class_id 3 4 UPDATE chipProcessedImfile 5 JOIN rawImfile USING(exp_id, class_id) 4 6 SET 5 data_state = '%s' 7 chipProcessedImfile.data_state = '%s' 8 -- set magicked hook %s 6 9 WHERE 7 10 chip_id = %lld -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_completely_processed_exp.sql
r20608 r23594 11 11 dvodb, 12 12 tess_id, 13 end_stage 13 end_stage, 14 all_files_magicked as magicked 14 15 FROM 15 16 (SELECT 16 17 chipRun.*, 17 18 rawImfile.class_id as rawimfile_class_id, 18 chipProcessedImfile.class_id 19 chipProcessedImfile.class_id, 20 SUM(!chipProcessedImfile.magicked) = 0 as all_files_magicked 19 21 FROM chipRun 20 22 JOIN rawImfile -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/chiptool_pendingimfile.sql
r21334 r23594 4 4 rawImfile.class_id, 5 5 rawImfile.uri, 6 rawImfile.magicked as raw_magicked, 7 (rawImfile.user_1 is not NULL and rawImfile.user_1 > 0.5) as deburned, 6 8 rawExp.exp_tag, 7 9 rawExp.exp_name, -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/difftool_completed_runs.sql
r20973 r23594 1 1 SELECT DISTINCT 2 diff_id 2 diff_id, 3 all_magicked as magicked 3 4 FROM ( 4 5 SELECT 5 6 COUNT(diffInputSkyfile.skycell_id), COUNT(diffSkyfile.skycell_id), 6 diffSkyfile.* 7 diffSkyfile.*, 8 SUM(!diffSkyfile.magicked) = 0 as all_magicked 7 9 FROM diffRun 8 10 JOIN diffInputSkyfile USING(diff_id) -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/difftool_inputskyfile.sql
r20976 r23594 9 9 warpSkyfile.uri, 10 10 warpSkyfile.path_base, 11 warpSkyfile.magicked as magicked, 11 12 0 as template, 12 13 rawExp.camera … … 47 48 warpSkyfile.uri, 48 49 warpSkyfile.path_base, 50 warpSkyfile.magicked as magicked, 49 51 1 as template, 50 52 rawExp.camera … … 85 87 stackSumSkyfile.uri, 86 88 stackSumSkyfile.path_base, 89 0 as magicked, 87 90 0 as template, 88 91 rawExp.camera … … 117 120 stackSumSkyfile.uri, 118 121 stackSumSkyfile.path_base, 122 0 as magicked, 119 123 1 as template, 120 124 rawExp.camera -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/disttool_pendingcomponent.sql
r23352 r23594 2 2 SELECT 3 3 distRun.dist_id, 4 distRun.label, 4 5 stage, 5 6 stage_id, … … 8 9 rawExp.camera, 9 10 outroot, 10 rawImfile.uri as path_base, 11 rawImfile.uri as path_base, -- change this once rawImfile has path_base 11 12 chipProcessedImfile.path_base as chip_path_base, 12 13 NULL as state, … … 15 16 FROM distRun 16 17 JOIN rawExp ON exp_id = stage_id 17 JOIN rawImfile using(exp_id) 18 JOIN ( -- find the last magicked chip run 19 SELECT 20 exp_id, 21 MAX(chip_id) AS chip_id 22 FROM chipRun 23 WHERE 24 chipRun.state = 'full' 25 AND chipRun.exp_id = exp_id 26 -- AND chipRun.magicked 27 -- magicked hook 1 %s 28 GROUP BY exp_id 29 ) AS bestChipRun 30 USING(exp_id) 31 JOIN rawImfile USING(exp_id) 18 32 JOIN chipProcessedImfile 19 ON distRun.chip_id = chipProcessedImfile.chip_id 20 AND rawImfile.class_id = chipProcessedImfile.class_id 33 USING(exp_id, chip_id, class_id) 21 34 LEFT JOIN distComponent 22 35 ON distRun.dist_id = distComponent.dist_id … … 26 39 AND distRun.stage = 'raw' 27 40 AND distComponent.dist_id IS NULL 41 -- if magicked add AND rawImfile.magicked here 42 -- where hook 1 %s 28 43 29 44 -- chip stage … … 31 46 SELECT 32 47 distRun.dist_id, 48 distRun.label, 33 49 stage, 34 50 stage_id, … … 53 69 AND distRun.stage = 'chip' 54 70 AND distComponent.dist_id IS NULL 55 UNION 56 SELECT 57 distRun.dist_id, 71 -- where hook 2 %s 72 UNION 73 SELECT 74 distRun.dist_id, 75 distRun.label, 76 stage, 77 stage_id, 78 chipProcessedImfile.class_id AS component, 79 clean, 80 rawExp.camera, 81 outroot, 82 camProcessedExp.path_base, 83 chipProcessedImfile.path_base as chip_path_base, 84 camRun.state, 85 NULL, 86 0 87 FROM distRun 88 JOIN camRun ON camRun.cam_id = distRun.stage_id 89 JOIN camProcessedExp USING(cam_id) 90 JOIN chipRun USING(chip_id) 91 JOIN chipProcessedImfile USING(exp_id, chip_id) 92 JOIN rawExp using(exp_id) 93 LEFT JOIN distComponent 94 ON distRun.dist_id = distComponent.dist_id 95 AND chipProcessedImfile.class_id = distComponent.component 96 WHERE 97 distRun.state = 'new' 98 AND distRun.stage = 'camera' 99 AND distComponent.dist_id IS NULL 100 -- where hook 3 %s 101 UNION 102 SELECT 103 distRun.dist_id, 104 distRun.label, 105 stage, 106 stage_id, 107 fakeProcessedImfile.class_id AS component, 108 clean, 109 rawExp.camera, 110 outroot, 111 fakeProcessedImfile.path_base, 112 NULL, 113 fakeRun.state, 114 NULL, 115 0 116 FROM distRun 117 JOIN fakeRun ON fakeRun.fake_id = distRun.stage_id 118 JOIN fakeProcessedImfile USING(fake_id) 119 JOIN camRun USING(cam_id) 120 JOIN chipRun USING(chip_id, exp_id) 121 JOIN rawExp using(exp_id) 122 LEFT JOIN distComponent 123 ON distRun.dist_id = distComponent.dist_id 124 AND fakeProcessedImfile.class_id = distComponent.component 125 WHERE 126 distRun.state = 'new' 127 AND distRun.stage = 'fake' 128 AND distComponent.dist_id IS NULL 129 -- where hook 4 %s 130 UNION 131 SELECT 132 distRun.dist_id, 133 distRun.label, 58 134 stage, 59 135 stage_id, … … 81 157 AND distRun.stage = 'warp' 82 158 AND distComponent.dist_id IS NULL 83 UNION 84 SELECT 85 distRun.dist_id, 159 -- where hook 5 %s 160 UNION 161 SELECT 162 distRun.dist_id, 163 distRun.label, 86 164 stage, 87 165 stage_id, … … 108 186 AND distRun.stage = 'diff' 109 187 AND distComponent.dist_id IS NULL 188 -- where hook 6 %s 110 189 UNION 111 190 SELECT DISTINCT 112 191 distRun.dist_id, 192 distRun.label, 113 193 stage, 114 194 stage_id, … … 152 232 AND distRun.stage = 'stack' 153 233 AND distComponent.dist_id IS NULL 234 -- where hook 7 %s 154 235 ) as Foo -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magicdstool_completed_runs.sql
r20973 r23594 12 12 AND magicDSFile.component = rawImfile.class_id 13 13 WHERE 14 magicDSRun.state = ' run'14 magicDSRun.state = 'new' 15 15 AND magicDSRun.stage = 'raw' 16 16 GROUP BY … … 30 30 AND magicDSFile.component = chipProcessedImfile.class_id 31 31 WHERE 32 magicDSRun.state = ' run'32 magicDSRun.state = 'new' 33 33 AND magicDSRun.stage = 'chip' 34 34 GROUP BY … … 48 48 AND magicDSFile.component = warpSkyfile.skycell_id 49 49 WHERE 50 magicDSRun.state = ' run'50 magicDSRun.state = 'new' 51 51 AND magicDSRun.stage = 'warp' 52 52 AND warpSkyfile.fault = 0 … … 72 72 AND magicDSFile.component = diffSkyfile.skycell_id 73 73 WHERE 74 magicDSRun.state = ' run'74 magicDSRun.state = 'new' 75 75 AND magicDSRun.stage = 'diff' 76 76 AND diffSkyfile.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magicdstool_todestreak.sql
r20973 r23594 26 26 AND magicDSFile.component = rawImfile.class_id 27 27 WHERE 28 magicDSRun.state = ' run'28 magicDSRun.state = 'new' 29 29 AND magicDSRun.stage = 'raw' 30 30 AND magicDSFile.component IS NULL … … 57 57 AND magicDSFile.component = chipProcessedImfile.class_id 58 58 WHERE 59 magicDSRun.state = ' run'59 magicDSRun.state = 'new' 60 60 AND magicDSRun.stage = 'chip' 61 61 AND chipRun.state = 'full' … … 91 91 AND magicDSFile.component = warpSkyfile.skycell_id 92 92 WHERE 93 magicDSRun.state = ' run'93 magicDSRun.state = 'new' 94 94 AND magicDSRun.stage = 'warp' 95 95 AND warpRun.state = 'full' … … 127 127 AND magicDSFile.component = diffSkyfile.skycell_id 128 128 WHERE 129 magicDSRun.state = ' run'129 magicDSRun.state = 'new' 130 130 AND magicDSRun.stage = 'diff' 131 131 AND diffSkyfile.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_addmask.sql
r18526 r23594 2 2 magicRun 3 3 SET 4 state = ' stop'4 state = 'full' 5 5 WHERE 6 state != ' stop'6 state != 'full' -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_chipprocessedimfile.sql
r20706 r23594 26 26 chipRun.state = 'full' 27 27 AND chipProcessedImfile.fault = 0 28 -- AND magicRun.state = ' stop'28 -- AND magicRun.state = 'full' 29 29 -- AND magicMask.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_diffskyfile.sql
r20701 r23594 24 24 diffRun.state = 'full' 25 25 AND diffSkyfile.fault = 0 26 -- AND magicRun.state = ' stop'26 -- AND magicRun.state = 'full' 27 27 -- AND magicMask.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_inputskyfile.sql
r20973 r23594 9 9 AND magicInputSkyfile.node = diffSkyfile.skycell_id 10 10 WHERE 11 magicRun.state = ' run'11 magicRun.state = 'new' -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_mask.sql
r20735 r23594 6 6 USING(magic_id) 7 7 WHERE 8 magicRun.state = ' stop'8 magicRun.state = 'full' 9 9 AND magicMask.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_rawimfile.sql
r20706 r23594 24 24 WHERE 25 25 rawImfile.fault = 0 26 -- AND magicRun.state = ' stop'26 -- AND magicRun.state = 'full' 27 27 -- AND magicMask.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_tomask.sql
r18781 r23594 10 10 LEFT JOIN magicNodeResult USING(magic_id, node) 11 11 WHERE 12 magicRun.state = ' run'12 magicRun.state = 'new' 13 13 AND magicNodeResult.node = 'root' 14 14 AND magicNodeResult.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_toprocess_inputs.sql
r21004 r23594 19 19 AND magicTree.node = magicNodeResult.node 20 20 WHERE 21 magicRun.state = ' run'21 magicRun.state = 'new' 22 22 AND magicNodeResult.magic_id IS NULL 23 23 AND magicNodeResult.node IS NULL -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_toprocess_tree.sql
r21099 r23594 15 15 AND magicTree.node = magicNodeResult.node 16 16 WHERE 17 magicRun.state = ' run'17 magicRun.state = 'new' 18 18 -- where hook %s 19 19 ORDER BY -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_toskyfilemask.sql
r15348 r23594 7 7 USING(magic_id) 8 8 WHERE 9 magicRun.state = ' run'9 magicRun.state = 'new' 10 10 AND magicSkyfileMask.magic_id IS NULL -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_totree.sql
r20474 r23594 12 12 USING(magic_id) 13 13 WHERE 14 magicRun.state = ' run'14 magicRun.state = 'new' 15 15 AND magicTree.node IS NULL 16 16 AND magicRun.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/magictool_warpskyfile.sql
r20701 r23594 21 21 warpRun.state = 'full' 22 22 AND warpSkyfile.fault = 0 23 -- AND magicRun.state = ' stop'23 -- AND magicRun.state = 'full' 24 24 -- AND magicMask.fault = 0 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/pxadmin_create_tables.sql
r23352 r23594 167 167 fault SMALLINT NOT NULL, 168 168 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 169 magicked TINYINT, 169 170 PRIMARY KEY(exp_id), 170 171 KEY(exp_name), … … 263 264 tess_id VARCHAR(64), 264 265 end_stage VARCHAR(64), 266 magicked TINYINT, 265 267 PRIMARY KEY(chip_id), 266 268 KEY(chip_id), KEY(exp_id), … … 826 828 end_stage VARCHAR(64), 827 829 registered DATETIME, 830 magicked TINYINT, 828 831 PRIMARY KEY(warp_id), 829 832 KEY(warp_id), … … 963 966 tess_id VARCHAR(64), 964 967 exp_id BIGINT, 968 magicked TINYINT, 965 969 PRIMARY KEY(diff_id), 966 970 KEY(diff_id), … … 1095 1099 stage_id BIGINT, 1096 1100 cam_id BIGINT, 1101 label VARCHAR(64), 1097 1102 outroot VARCHAR(255), 1098 1103 recoveryroot VARCHAR(255), … … 1102 1107 KEY(magic_ds_id), 1103 1108 KEY(state), 1109 KEY(magic_id), 1110 KEY(label), 1104 1111 FOREIGN KEY (magic_id) REFERENCES magicRun(magic_id) 1105 1112 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 1225 1232 KEY(job_id), 1226 1233 FOREIGN KEY (req_id) REFERENCES pstampRequest(req_id) 1227 ) ENGINE=innodb DEFAULT CHARSET=latin1 1234 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1235 1236 CREATE TABLE distTarget ( 1237 target_id BIGINT AUTO_INCREMENT, 1238 obs_mode VARCHAR(64), 1239 stage VARCHAR(64), 1240 clean TINYINT, 1241 state VARCHAR(64), 1242 comment VARCHAR(255), 1243 PRIMARY KEY(target_id) 1244 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1245 1246 CREATE TABLE distRun ( 1247 dist_id BIGINT AUTO_INCREMENT, 1248 target_id BIGINT, 1249 stage VARCHAR(64), 1250 stage_id BIGINT, 1251 label VARCHAR(64), 1252 outroot VARCHAR(255), 1253 clean TINYINT, 1254 state VARCHAR(64), 1255 time_stamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 1256 fault SMALLINT, 1257 PRIMARY KEY(dist_id), 1258 KEY(state), 1259 KEY(label), 1260 FOREIGN KEY(target_id) REFERENCES distTarget(target_id) 1261 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1262 1263 CREATE TABLE distComponent ( 1264 dist_id BIGINT, 1265 component VARCHAR(64), 1266 bytes INT, 1267 md5sum VARCHAR(32), 1268 state VARCHAR(64), 1269 name VARCHAR(255), 1270 fault SMALLINT, 1271 PRIMARY KEY(dist_id, component), 1272 KEY(state), 1273 FOREIGN KEY(dist_id) REFERENCES distRun(dist_id) 1274 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1275 1276 1277 CREATE TABLE rcDSProduct ( 1278 prod_id BIGINT AUTO_INCREMENT, 1279 name VARCHAR(64), 1280 dbname VARCHAR(64), 1281 dbhost VARCHAR(64), 1282 prod_root VARCHAR(255), 1283 PRIMARY KEY(prod_id) 1284 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1285 1286 CREATE TABLE rcDestination ( 1287 dest_id BIGINT AUTO_INCREMENT, 1288 prod_id BIGINT, 1289 name VARCHAR(64), 1290 status_uri VARCHAR(255), 1291 comment VARCHAR(255), 1292 last_fileset VARCHAR(255), 1293 state VARCHAR(64), 1294 PRIMARY KEY(dest_id), 1295 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 1296 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1297 1298 1299 CREATE TABLE rcInterest ( 1300 int_id BIGINT AUTO_INCREMENT, 1301 dest_id BIGINT, 1302 target_id BIGINT, 1303 prod_id BIGINT, 1304 state VARCHAR(64), 1305 PRIMARY KEY(int_id), 1306 FOREIGN KEY(dest_id) REFERENCES rcDestination(dest_id), 1307 FOREIGN KEY(target_id) REFERENCES distTarget(target_id), 1308 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 1309 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1310 1311 CREATE TABLE rcDSFileset ( 1312 fs_id BIGINT AUTO_INCREMENT, 1313 dist_id BIGINT, 1314 prod_id BIGINT, 1315 name VARCHAR(64), 1316 state VARCHAR(64), 1317 registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 1318 PRIMARY KEY(fs_id), 1319 FOREIGN KEY(dist_id) REFERENCES distRun(dist_id), 1320 FOREIGN KEY(prod_id) REFERENCES rcDSProduct(prod_id) 1321 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1322 1323 CREATE TABLE rcRun ( 1324 rc_id BIGINT AUTO_INCREMENT, 1325 fs_id BIGINT, 1326 dest_id BIGINT, 1327 state VARCHAR(64), 1328 registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 1329 PRIMARY KEY(rc_id), 1330 FOREIGN KEY(fs_id) REFERENCES rcDSFileset(fs_id), 1331 FOREIGN KEY(dest_id) REFERENCES rcDestination(dest_id) 1332 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1333 1334 1335 1336 -- This comment line is here to avoid empty query error. 1337 -- Another way to avoid that problem is to omit the semicolon above but I think that is untidy. -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/pxadmin_drop_tables.sql
r21308 r23594 54 54 DROP TABLE IF EXISTS calRun; 55 55 DROP TABLE IF EXISTS flatcorrRun; 56 DROP TABLE IF EXISTS flatcorrExp; 56 57 DROP TABLE IF EXISTS flatcorrChipLink; 57 58 DROP TABLE IF EXISTS flatcorrCamLink; … … 60 61 DROP TABLE IF EXISTS pstampRequest; 61 62 DROP TABLE IF EXISTS pstampJob; 63 DROP TABLE IF EXISTS distRun; 64 DROP TABLE IF EXISTS distTarget; 65 DROP TABLE IF EXISTS distComponent; 66 DROP TABLE IF EXISTS rcDSProduct; 67 DROP TABLE IF EXISTS rcDestination; 68 DROP TABLE IF EXISTS rcInterest; 69 DROP TABLE IF EXISTS rcDSFileset; 70 DROP TABLE IF EXISTS rcRun; 71 62 72 SET FOREIGN_KEY_CHECKS=1 -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/pztool_find_completed_exp.sql
r17925 r23594 1 1 SELECT DISTINCT 2 exp_name, -- return should match pzDownloadExp2 exp_name, 3 3 camera, 4 4 telescope, 5 state, 6 NULL as epoch -- epoch 5 state 7 6 FROM ( 8 7 SELECT -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_change_skyfile_data_state.sql
r23352 r23594 8 8 warp_id = %lld 9 9 AND skycell_id = '%s' 10 -- only update if chipRun.state has the expected value11 -- AND (12 -- SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id13 -- ) = '%s' -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_definebyquery.sql
r20041 r23594 9 9 rawExp.dateobs, 10 10 rawExp.exp_tag, 11 rawExp.exp_name, 11 12 rawExp.exp_type, 12 13 rawExp.filelevel, -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_pendingcleanuprun.sql
r19521 r23594 13 13 USING (exp_id) 14 14 WHERE 15 (warpRun.state = 'goto_cleaned' OR warpRun.state = 'goto_ purged')15 (warpRun.state = 'goto_cleaned' OR warpRun.state = 'goto_scrubbed' OR warpRun.state = 'goto_purged') -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_pendingcleanupskyfile.sql
r19521 r23594 10 10 USING(warp_id) 11 11 WHERE 12 (warpRun.state = 'goto_cleaned'AND warpSkyfile.data_state = 'full')12 ((warpRun.state = 'goto_cleaned' AND warpSkyfile.data_state = 'full') 13 13 OR 14 (warpRun.state = 'goto_purged' AND warpSkyfile.data_state != 'purged') 14 (warpRun.state = 'goto_scrubbed' AND warpSkyfile.data_state = 'full') 15 OR 16 (warpRun.state = 'goto_purged' AND warpSkyfile.data_state != 'purged')) -
branches/cnb_branches/cnb_branch_20090301/ippTools/share/warptool_towarped.sql
r21308 r23594 9 9 rawExp.camera, 10 10 rawExp.exp_tag, 11 warpRun.workdir 11 warpRun.workdir, 12 chipRun.magicked 12 13 FROM warpRun 13 14 JOIN warpSkyCellMap -
branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Property svn:ignore
-
old new 32 32 flatcorr 33 33 pstamptool 34 disttool
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/Makefile.am
r20789 r23594 6 6 dettool \ 7 7 difftool \ 8 disttool \ 8 9 flatcorr \ 9 10 magictool \ … … 45 46 dettool.h \ 46 47 difftool.h \ 48 disttool.h \ 47 49 flatcorr.h \ 48 50 faketool.h \ … … 152 154 difftoolConfig.c 153 155 156 disttool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) 157 disttool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la 158 disttool_SOURCES = \ 159 disttool.c \ 160 disttoolConfig.c 161 154 162 stacktool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) 155 163 stacktool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.c
r23352 r23594 109 109 psMetadata *where = psMetadataAlloc(); 110 110 pxcamGetSearchArgs (config, where); 111 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 111 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 112 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 112 113 113 114 if (!psListLength(where->list) … … 223 224 224 225 psMetadata *where = psMetadataAlloc(); 225 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");226 226 pxcamGetSearchArgs (config, where); 227 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 228 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 227 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 228 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 229 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 230 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 229 231 230 232 if (!psListLength(where->list) … … 271 273 272 274 psMetadata *where = psMetadataAlloc(); 273 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");274 275 pxcamGetSearchArgs (config, where); 275 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 276 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 277 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 278 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 276 279 277 280 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 334 337 335 338 psMetadata *where = psMetadataAlloc(); 336 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");337 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");338 PXOPT_COPY_STR(config->args, where, "-class", "class", "==");339 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");340 339 pxcamGetSearchArgs (config, where); 341 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 340 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 341 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 342 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 343 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 344 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 345 346 // XXX is this used? PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 342 347 343 348 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 649 654 // generate restrictions 650 655 psMetadata *where = psMetadataAlloc(); 651 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");652 656 pxcamGetSearchArgs (config, where); 653 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 657 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 658 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 659 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 654 660 655 661 psString query = pxDataGet("camtool_find_processedexp.sql"); … … 674 680 } 675 681 682 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry 683 psStringAppend(&query, " ORDER BY cam_id"); 684 676 685 // treat limit == 0 as "no limit" 677 686 if (limit) { … … 681 690 } 682 691 683 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry684 psStringAppend(&query, "\nORDER BY cam_id");685 686 692 if (!p_psDBRunQuery(config->dbh, query)) { 687 693 psError(PS_ERR_UNKNOWN, false, "database error"); … … 720 726 721 727 psMetadata *where = psMetadataAlloc(); 722 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "==");723 728 pxcamGetSearchArgs (config, where); 724 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 725 PXOPT_COPY_S16(config->args, where, "-code", "camProcessedExp.fault", "=="); 729 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 730 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 731 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 732 PXOPT_COPY_S16(config->args, where, "-code", "camProcessedExp.fault", "=="); 726 733 727 734 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtoolConfig.c
r23352 r23594 52 52 psMetadata *definebyqueryArgs = psMetadataAlloc(); 53 53 pxcamSetSearchArgs(definebyqueryArgs); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search by chipRun label", NULL); 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by chipRun reduction class", NULL); 55 56 56 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 68 69 // XXX need to allow multiple exp_ids 69 70 psMetadata *updaterunArgs = psMetadataAlloc(); 71 pxcamSetSearchArgs(updaterunArgs); 70 72 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 71 pxcamSetSearchArgs(updaterunArgs); 72 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 73 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search for state", NULL); 74 73 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 74 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by camRun state", NULL); 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 75 76 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 76 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL);77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL);77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 78 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 78 79 79 80 // -pendingexp 80 81 psMetadata *pendingexpArgs = psMetadataAlloc(); 81 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);82 82 pxcamSetSearchArgs(pendingexpArgs); 83 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 83 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 84 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 85 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 84 86 psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 85 87 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); … … 87 89 // -pendingimfile 88 90 psMetadata *pendingimfileArgs = psMetadataAlloc(); 89 psMetadataAddS64(pendingimfileArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);90 91 pxcamSetSearchArgs(pendingimfileArgs); 91 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 92 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, "search by class", NULL); 92 psMetadataAddS64(pendingimfileArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0); 93 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 94 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 93 95 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 94 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 96 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 97 98 // XXX is this used? psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, "search by class", NULL); 95 99 96 100 // -addprocessedexp … … 165 169 // -processedexp 166 170 psMetadata *processedexpArgs = psMetadataAlloc(); 167 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);168 171 pxcamSetSearchArgs(processedexpArgs); 169 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 172 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 173 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 174 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 170 175 171 176 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); … … 178 183 // XXX need to allow multiple exp_ids 179 184 psMetadata *revertprocessedexpArgs = psMetadataAlloc(); 180 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0);181 185 pxcamSetSearchArgs(revertprocessedexpArgs); 182 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 186 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 187 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 188 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 189 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 183 190 184 191 psMetadataAddBool(revertprocessedexpArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 185 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);186 192 187 193 // -updateprocessedexp -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c
r23352 r23594 209 209 return false; 210 210 } 211 211 // 212 212 // queue the exp 213 213 if (!pxchipQueueByExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) { … … 415 415 PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false); 416 416 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 417 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 417 418 418 419 // default values … … 490 491 path_base, 491 492 code, 492 0 // magic_ds_id493 magicked 493 494 )) { 494 495 // rollback … … 540 541 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 541 542 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE"); 543 PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "=="); 542 544 543 545 psString query = pxDataGet("chiptool_processedimfile.sql"); … … 1137 1139 } 1138 1140 1139 // set chipRun.state to 'stop' 1140 if (!pxchipRunSetState(config, chipRun->chip_id, "full" )) {1141 // set chipRun.state to 'stop' and update the magicked state 1142 if (!pxchipRunSetState(config, chipRun->chip_id, "full", chipRun->magicked)) { 1141 1143 psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id); 1142 1144 psFree(chipRun); … … 1209 1211 } 1210 1212 1213 psString set_magic = ""; 1214 if (!strcmp(data_state, "full")) { 1215 // copy the magicked state from the input to the output when transitioning to full state 1216 set_magic = "\n , chipProcessedImfile.magicked = rawImfile.magicked"; 1217 } 1218 1211 1219 // note only updates if chipRun.state = run_state 1212 if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) { 1220 // XXX note that we have removed this constraint for now 1221 if (!p_psDBRunQueryF(config->dbh, query, data_state, set_magic, chip_id, class_id)) { 1222 psFree(query); 1213 1223 psError(PS_ERR_UNKNOWN, false, "database error"); 1214 1224 // rollback … … 1227 1237 query = pxDataGet("chiptool_change_exp_state.sql"); 1228 1238 if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, data_state)) { 1239 psFree(query); 1229 1240 // rollback 1230 1241 if (!psDBRollback(config->dbh)) { … … 1234 1245 return false; 1235 1246 } 1247 psFree(query); 1236 1248 1237 1249 if (!psDBCommit(config->dbh)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptoolConfig.c
r23352 r23594 66 66 pxchipSetSearchArgs (updaterunArgs); 67 67 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "se tstate", NULL);68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 69 69 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 70 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); … … 147 147 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 148 148 psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 149 psMetadataAddBool(addprocessedimfileArgs, PS_LIST_TAIL, "-magicked", 0, "define magicked status", false); 149 150 150 151 // -processedimfile … … 155 156 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 156 157 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-label", 0, "search by chipRun label (LIKE comparison)", NULL); 158 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-magicked", 0, "search by magicked status", false); 157 159 pxchipSetSearchArgs(processedimfileArgs); 158 160 psMetadataAddU64(processedimfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.c
r23352 r23594 41 41 static bool definepoprunMode(pxConfig *config); 42 42 static bool definebyqueryMode(pxConfig *config); 43 static bool definewarpwarpMode(pxConfig *config); 43 44 static bool pendingcleanuprunMode(pxConfig *config); 44 45 static bool pendingcleanupskyfileMode(pxConfig *config); … … 48 49 static bool importrunMode(pxConfig *config); 49 50 50 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state );51 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked); 51 52 static bool diffRunComplete(pxConfig *config); 52 53 … … 79 80 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 80 81 MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 82 MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpMode); 81 83 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 82 84 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); … … 131 133 registered, 132 134 tess_id, 133 exp_id 135 exp_id, 136 false 134 137 ); 135 138 if (!run) { … … 168 171 if (state) { 169 172 // set detRun.state to state 170 return setdiffRunState(config, diff_id, state );173 return setdiffRunState(config, diff_id, state, false); 171 174 } 172 175 … … 282 285 283 286 if (count == 2) { 284 if (!setdiffRunState(config, diff_id, "new" )) {287 if (!setdiffRunState(config, diff_id, "new", false)) { 285 288 if (!psDBRollback(config->dbh)) { 286 289 psError(PS_ERR_UNKNOWN, false, "database error"); … … 506 509 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 507 510 PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false); 511 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 508 512 509 513 if (!psDBTransaction(config->dbh)) { … … 537 541 good_frac, 538 542 code, 539 0 // magic_ds_id543 magicked 540 544 )) { 541 545 if (!psDBRollback(config->dbh)) { … … 730 734 731 735 732 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state )736 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked) 733 737 { 734 738 PS_ASSERT_PTR_NON_NULL(state, false); … … 740 744 } 741 745 742 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 743 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 746 char *query = "UPDATE diffRun SET state = '%s', magicked = %d WHERE diff_id = %"PRId64; 747 748 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 744 749 psError(PS_ERR_UNKNOWN, false, 745 750 "failed to change state for diff_id %"PRId64, diff_id); … … 792 797 registered, 793 798 tess_id, 794 exp_id 799 exp_id, 800 false // magicked 795 801 ); 796 802 … … 1002 1008 psTrace("difftool", 1, query, warpQuery, diffQuery, expQuery, stackQuery); 1003 1009 1010 if (!psDBTransaction(config->dbh)) { 1011 psError(PS_ERR_UNKNOWN, false, "database error"); 1012 return false; 1013 } 1004 1014 1005 1015 if (!p_psDBRunQueryF(config->dbh, query, warpQuery, expQuery, diffQuery)) { 1006 1016 psError(PS_ERR_UNKNOWN, false, "database error"); 1007 1017 psFree(query); 1018 if (!psDBRollback(config->dbh)) { 1019 psError(PS_ERR_UNKNOWN, false, "database error"); 1020 } 1008 1021 return false; 1009 1022 } … … 1014 1027 psErrorCode err = psErrorCodeLast(); 1015 1028 switch (err) { 1016 case PS_ERR_DB_CLIENT: 1017 psError(PXTOOLS_ERR_SYS, false, "database error"); 1018 case PS_ERR_DB_SERVER: 1019 psError(PXTOOLS_ERR_PROG, false, "database error"); 1020 default: 1021 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1022 } 1023 1029 case PS_ERR_DB_CLIENT: 1030 psError(PXTOOLS_ERR_SYS, false, "database error"); 1031 break; 1032 case PS_ERR_DB_SERVER: 1033 psError(PXTOOLS_ERR_PROG, false, "database error"); 1034 break; 1035 default: 1036 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1037 break; 1038 } 1039 if (!psDBRollback(config->dbh)) { 1040 psError(PS_ERR_UNKNOWN, false, "database error"); 1041 } 1024 1042 return false; 1025 1043 } … … 1027 1045 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1028 1046 psFree(output); 1047 if (!psDBCommit(config->dbh)) { 1048 psError(PS_ERR_UNKNOWN, false, "database error"); 1049 return false; 1050 } 1029 1051 return true; 1030 1052 } … … 1035 1057 psError(PS_ERR_UNKNOWN, false, "database error"); 1036 1058 psFree(query); 1059 if (!psDBRollback(config->dbh)) { 1060 psError(PS_ERR_UNKNOWN, false, "database error"); 1061 } 1037 1062 return false; 1038 1063 } … … 1055 1080 if (!mdok) { 1056 1081 psError(PXTOOLS_ERR_PROG, false, "exp_id not found"); 1082 if (!psDBRollback(config->dbh)) { 1083 psError(PS_ERR_UNKNOWN, false, "database error"); 1084 } 1057 1085 return false; 1058 1086 } … … 1068 1096 psFree(stackQuery); 1069 1097 psFree(skycell_query); 1098 if (!psDBRollback(config->dbh)) { 1099 psError(PS_ERR_UNKNOWN, false, "database error"); 1100 } 1070 1101 return false; 1071 1102 } … … 1076 1107 psFree(stackQuery); 1077 1108 psFree(skycell_query); 1109 if (!psDBRollback(config->dbh)) { 1110 psError(PS_ERR_UNKNOWN, false, "database error"); 1111 } 1078 1112 return false; 1079 1113 } … … 1084 1118 psFree(stackQuery); 1085 1119 psFree(skycell_query); 1120 if (!psDBRollback(config->dbh)) { 1121 psError(PS_ERR_UNKNOWN, false, "database error"); 1122 } 1086 1123 return false; 1087 1124 } … … 1092 1129 psFree(stackQuery); 1093 1130 psFree(skycell_query); 1131 if (!psDBRollback(config->dbh)) { 1132 psError(PS_ERR_UNKNOWN, false, "database error"); 1133 } 1094 1134 return false; 1095 1135 } … … 1100 1140 psFree(stackQuery); 1101 1141 psFree(skycell_query); 1142 if (!psDBRollback(config->dbh)) { 1143 psError(PS_ERR_UNKNOWN, false, "database error"); 1144 } 1102 1145 return false; 1103 1146 } … … 1107 1150 psFree(stackQuery); 1108 1151 psFree(skycell_query); 1152 if (!psDBRollback(config->dbh)) { 1153 psError(PS_ERR_UNKNOWN, false, "database error"); 1154 } 1109 1155 return false; 1110 1156 } … … 1132 1178 registered, 1133 1179 tess_id, 1134 exp_id 1180 exp_id, 1181 false // magicked 1135 1182 ); 1136 1183 … … 1138 1185 psError(PS_ERR_UNKNOWN, false, "database error"); 1139 1186 psFree(run); 1140 return true; 1187 if (!psDBRollback(config->dbh)) { 1188 psError(PS_ERR_UNKNOWN, false, "database error"); 1189 } 1190 return false; 1141 1191 } 1142 1192 run->diff_id = psDBLastInsertID(config->dbh); … … 1149 1199 psFree(skycell_query); 1150 1200 psFree(query); 1201 if (!psDBRollback(config->dbh)) { 1202 psError(PS_ERR_UNKNOWN, false, "database error"); 1203 } 1151 1204 return false; 1152 1205 } … … 1160 1213 psFree(skycell_query); 1161 1214 psFree(query); 1215 if (!psDBRollback(config->dbh)) { 1216 psError(PS_ERR_UNKNOWN, false, "database error"); 1217 } 1162 1218 return false; 1163 1219 } … … 1165 1221 query = NULL; 1166 1222 1167 if (!setdiffRunState(config, run->diff_id, "new" )) {1223 if (!setdiffRunState(config, run->diff_id, "new", false)) { 1168 1224 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1169 1225 run->diff_id); … … 1172 1228 psFree(skycell_query); 1173 1229 psFree(query); 1230 if (!psDBRollback(config->dbh)) { 1231 psError(PS_ERR_UNKNOWN, false, "database error"); 1232 } 1174 1233 return false; 1175 1234 } … … 1183 1242 psFree(skycell_query); 1184 1243 1244 if (!psDBCommit(config->dbh)) { 1245 psError(PS_ERR_UNKNOWN, false, "database error"); 1246 psFree(list); 1247 return false; 1248 } 1249 1185 1250 if (!diffRunPrintObjects(stdout, list, !simple)) { 1186 1251 psError(PS_ERR_UNKNOWN, false, "failed to print object"); … … 1192 1257 return true; 1193 1258 } 1259 1260 static bool definewarpwarpMode(pxConfig *config) 1261 { 1262 PS_ASSERT_PTR_NON_NULL(config, false); 1263 1264 psMetadata *selectWhere = psMetadataAlloc(); 1265 psMetadata *insertWhere = psMetadataAlloc(); 1266 1267 // Restrictions for selecting warps 1268 PXOPT_COPY_S64(config->args, selectWhere, "-warp_id", "inputWarpRun.warp_id", "=="); 1269 PXOPT_COPY_S64(config->args, selectWhere, "-exp_id", "inputRawExp.exp_id", "=="); 1270 PXOPT_COPY_STR(config->args, selectWhere, "-filter", "inputRawExp.filter", "=="); 1271 PXOPT_COPY_STR(config->args, selectWhere, "-input_label", "inputWarpRun.label", "=="); 1272 PXOPT_COPY_STR(config->args, selectWhere, "-template_label", "templateWarpRun.label", "=="); 1273 PXOPT_COPY_F32(config->args, selectWhere, "-timediff", 1274 "ABS(TIME_TO_SEC(TIMEDIFF(inputRawExp.dateobs, templateRawExp.dateobs)))", "<="); 1275 PXOPT_COPY_F32(config->args, selectWhere, "-rotdiff", "ABS(inputRawExp.posang - templateRawExp.posang)", "<="); 1276 1277 // Restrictions for inserting skycells 1278 PXOPT_COPY_F32(config->args, insertWhere, "-good_frac", "inputWarpSkyfile.good_frac", ">="); 1279 PXOPT_COPY_F32(config->args, insertWhere, "-good_frac", "templateWarpSkyfile.good_frac", ">="); 1280 1281 // Additional controls 1282 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 1283 PXOPT_LOOKUP_BOOL(available, config->args, "-available", false); 1284 1285 // Settings to apply to defined run 1286 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1287 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1288 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1289 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1290 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1291 1292 1293 psString select = pxDataGet("difftool_definewarpwarp_select.sql"); 1294 if (!select) { 1295 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1296 return false; 1297 } 1298 1299 psString whereClause = NULL; // The WHERE part of the query 1300 1301 if (psListLength(selectWhere->list)) { 1302 psString new = psDBGenerateWhereConditionSQL(selectWhere, NULL); 1303 psStringAppend(&whereClause, "\n%s %s", whereClause ? "AND" : "WHERE", new); 1304 psFree(new); 1305 } 1306 psFree(selectWhere); 1307 1308 if (!rerun) { 1309 psStringAppend(&whereClause, "\n%s diffRun.diff_id IS NULL", whereClause ? "AND" : "WHERE"); 1310 } 1311 1312 if (!available) { 1313 psStringAppend(&whereClause, "\n%s inputWarpRun.state = 'full'", whereClause ? "AND" : "WHERE"); 1314 } 1315 1316 if (!psDBTransaction(config->dbh)) { 1317 psError(PS_ERR_UNKNOWN, false, "database error"); 1318 psFree(select); 1319 psFree(whereClause); 1320 psFree(insertWhere); 1321 return false; 1322 } 1323 1324 if (!p_psDBRunQueryF(config->dbh, select, 1325 !rerun ? "\n" : "", // Activate LEFT JOIN against diffRun? 1326 whereClause)) { 1327 psError(PS_ERR_UNKNOWN, false, "Unable to run query: %s [WITH] %s", select, whereClause); 1328 psFree(select); 1329 psFree(whereClause); 1330 psFree(insertWhere); 1331 if (!psDBRollback(config->dbh)) { 1332 psError(PS_ERR_UNKNOWN, false, "database error"); 1333 } 1334 return false; 1335 } 1336 psFree(select); 1337 psFree(whereClause); 1338 1339 psArray *results = p_psDBFetchResult(config->dbh); // Results of query 1340 if (!results) { 1341 psErrorCode err = psErrorCodeLast(); // Code for error 1342 switch (err) { 1343 case PS_ERR_DB_CLIENT: 1344 psError(PXTOOLS_ERR_SYS, false, "database error"); 1345 break; 1346 case PS_ERR_DB_SERVER: 1347 psError(PXTOOLS_ERR_PROG, false, "database error"); 1348 break; 1349 default: 1350 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1351 break; 1352 } 1353 if (!psDBRollback(config->dbh)) { 1354 psError(PS_ERR_UNKNOWN, false, "database error"); 1355 } 1356 psFree(insertWhere); 1357 return false; 1358 } 1359 if (!psArrayLength(results)) { 1360 psTrace("difftool", 1, "no rows found"); 1361 psFree(results); 1362 psFree(insertWhere); 1363 if (!psDBCommit(config->dbh)) { 1364 psError(PS_ERR_UNKNOWN, false, "database error"); 1365 return false; 1366 } 1367 return true; 1368 } 1369 1370 psString insert = pxDataGet("difftool_definewarpwarp_insert.sql"); // Insertion for each new run 1371 1372 if (psListLength(insertWhere->list)) { 1373 psString whereClause = psDBGenerateWhereConditionSQL(insertWhere, NULL); 1374 psStringAppend(&insert, "\n%s", whereClause); 1375 psFree(whereClause); 1376 } 1377 psFree(insertWhere); 1378 1379 psArray *list = psArrayAllocEmpty(16); // List of runs defined, to print 1380 long numGood = 0; // Number of good rows added 1381 for (long i = 0; i < results->n; i++) { 1382 psMetadata *row = results->data[i]; // Result row from query 1383 1384 psS64 exp_id = psMetadataLookupS64(NULL, row, "input_exp_id"); 1385 psS64 input_id = psMetadataLookupS64(NULL, row, "input_warp_id"); 1386 psS64 template_id = psMetadataLookupS64(NULL, row, "template_warp_id"); 1387 const char *tess_id = psMetadataLookupStr(NULL, row, "tess_id"); 1388 if (!exp_id || !input_id || !template_id || !tess_id) { 1389 psError(PXTOOLS_ERR_PROG, false, "Identifiers not found"); 1390 psFree(list); 1391 psFree(insert); 1392 psFree(results); 1393 if (!psDBRollback(config->dbh)) { 1394 psError(PS_ERR_UNKNOWN, false, "database error"); 1395 } 1396 return false; 1397 } 1398 1399 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered, 1400 tess_id, exp_id, false); // Run to insert 1401 if (!diffRunInsertObject(config->dbh, run)) { 1402 psError(PS_ERR_UNKNOWN, false, "database error"); 1403 psFree(run); 1404 psFree(list); 1405 psFree(insert); 1406 psFree(results); 1407 if (!psDBRollback(config->dbh)) { 1408 psError(PS_ERR_UNKNOWN, false, "database error"); 1409 } 1410 return false; 1411 } 1412 run->diff_id = psDBLastInsertID(config->dbh); // Difference run identifier 1413 1414 // Convert identifiers to string, for insertion into query 1415 psString diff = NULL, input = NULL, template = NULL; // String versions of identifiers 1416 psStringAppend(&diff, "%" PRId64, run->diff_id); 1417 psStringAppend(&input, "%" PRId64, input_id); 1418 psStringAppend(&template, "%" PRId64, template_id); 1419 1420 if (!p_psDBRunQueryF(config->dbh, insert, diff, input, template, input, template)) { 1421 psError(PS_ERR_UNKNOWN, false, "database error"); 1422 psFree(input); 1423 psFree(template); 1424 psFree(diff); 1425 psFree(run); 1426 psFree(list); 1427 psFree(insert); 1428 psFree(results); 1429 if (!psDBRollback(config->dbh)) { 1430 psError(PS_ERR_UNKNOWN, false, "database error"); 1431 } 1432 return false; 1433 } 1434 psFree(input); 1435 psFree(template); 1436 psFree(diff); 1437 1438 if (!setdiffRunState(config, run->diff_id, "new", false)) { 1439 psError(PS_ERR_UNKNOWN, false, "Failed to change diffRun.state for diff_id: %" PRId64, 1440 run->diff_id); 1441 psFree(run); 1442 psFree(list); 1443 psFree(insert); 1444 psFree(results); 1445 if (!psDBRollback(config->dbh)) { 1446 psError(PS_ERR_UNKNOWN, false, "database error"); 1447 } 1448 return false; 1449 } 1450 1451 psArrayAdd(list, list->n, run); 1452 psFree(run); // Drop reference 1453 1454 numGood++; 1455 } 1456 psFree(insert); 1457 psFree(results); 1458 1459 if (!psDBCommit(config->dbh)) { 1460 psError(PS_ERR_UNKNOWN, false, "database error"); 1461 psFree(list); 1462 return false; 1463 } 1464 1465 if (!diffRunPrintObjects(stdout, list, !simple)) { 1466 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 1467 psFree(list); 1468 return false; 1469 } 1470 psFree(list); 1471 1472 return true; 1473 } 1474 1194 1475 1195 1476 static bool pendingcleanuprunMode(pxConfig *config) … … 1428 1709 1429 1710 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1711 bool magicked = psMetadataLookupBool(NULL, row, "magicked"); 1430 1712 1431 1713 // set diffRun.state to 'stop' 1432 if (!setdiffRunState(config, diff_id, "full" )) {1714 if (!setdiffRunState(config, diff_id, "full", magicked)) { 1433 1715 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1434 1716 diff_id); … … 1447 1729 char sqlFilename[80]; 1448 1730 } ExportTable; 1449 1731 1450 1732 int numExportFiles = 3; 1451 1733 … … 1526 1808 { 1527 1809 unsigned int nFail; 1528 1810 1529 1811 int numImportTables = 2; 1530 1812 1531 1813 char tables[2] [80] = {"diffInputSkyfile", "diffSkyfile"}; 1532 1814 1533 1815 PS_ASSERT_PTR_NON_NULL(config, NULL); 1534 1816 1535 1817 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1536 1818 … … 1557 1839 psAssert (item, "entry not in input?"); 1558 1840 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1559 1841 1560 1842 switch (i) { 1561 1843 case 0: … … 1571 1853 } 1572 1854 break; 1573 1855 1574 1856 case 1: 1575 1857 for (int i = 0; i < item->data.list->n; i++) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.h
r23352 r23594 35 35 DIFFTOOL_MODE_DEFINEPOPRUN, 36 36 DIFFTOOL_MODE_DEFINEBYQUERY, 37 DIFFTOOL_MODE_DEFINEWARPWARP, 37 38 DIFFTOOL_MODE_PENDINGCLEANUPRUN, 38 39 DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftoolConfig.c
r23352 r23594 107 107 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-kernel_xy", 0, "define kernel xy moment", NAN); 108 108 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-kernel_yy", 0, "define kernel yy moment", NAN); 109 psMetadataAddS32(adddiffskyfileArgs, PS_LIST_TAIL, "-sources", 0, "define number of sources", 0); 110 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 111 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 109 psMetadataAddS32(adddiffskyfileArgs, PS_LIST_TAIL, "-sources", 0, "define number of sources", 0); 110 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 111 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 112 psMetadataAddBool(adddiffskyfileArgs, PS_LIST_TAIL, "-magicked", 0, "define magicked state", false); 112 113 113 114 // -diffskyfile … … 164 165 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 165 166 167 // -definewarpwarp 168 psMetadata *definewarpwarpArgs = psMetadataAlloc(); 169 psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 170 psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 171 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-filter", 0, "search by filter", NULL); 172 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-timediff", 0, "limit time difference between input and template", NAN); 173 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-rotdiff", 0, "limit rotator difference between input and template", NAN); 174 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-input_label", 0, "search by warp label for input", NULL); 175 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-template_label", 0, "search by warp label for template", NULL); 176 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-good_frac", 0, "minimum good fraction of skycell", NAN); 177 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 178 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 179 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction class", NULL); 180 psMetadataAddTime(definewarpwarpArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 181 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false); 182 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-available", 0, "define new run even if warpRun has some faults", false); 183 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 184 166 185 // -pendingcleanuprun 167 186 psMetadata *pendingcleanuprunArgs = psMetadataAlloc(); … … 214 233 PXOPT_ADD_MODE("-definepoprun", "", DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunArgs); 215 234 PXOPT_ADD_MODE("-definebyquery", "", DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 235 PXOPT_ADD_MODE("-definewarpwarp", "", DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpArgs); 216 236 PXOPT_ADD_MODE("-pendingcleanuprun", "show runs that need to be cleaned up", DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunArgs); 217 237 PXOPT_ADD_MODE("-pendingcleanupskyfile", "show runs that need to be cleaned up", DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileArgs); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/disttool.c
r23352 r23594 98 98 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 99 99 100 bool require_chip_id = false;101 if (!strcmp(stage, "raw")) {102 // need to know the chip id for raw stage so that we can find the masks103 require_chip_id = true;104 }105 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", require_chip_id, false);106 107 100 // TODO: check that stage has an expected value 101 // XXX: all of the following concerns will be managed properly by definebyquery 102 108 103 // TODO: check that stage_id actually exists for stage 109 104 // in magicdstool we queue off of a magic_id so the stage_id, exp_id, and cam_id get looked up … … 113 108 // change between the time that it is queued. 114 109 115 if (!distRunInsert(config->dbh, 0, stage, stage_id, chip_id, set_label, outroot, clean, "new", 0)) {110 if (!distRunInsert(config->dbh, 0, stage, stage_id, set_label, outroot, clean, "new", NULL, 0)) { 116 111 psError(PS_ERR_UNKNOWN, false, "database error"); 117 112 return false; … … 151 146 } 152 147 153 psString query = psStringCopy("UPDATE distRun ");148 psString query = psStringCopy("UPDATE distRun SET time_stamp = UTC_TIMESTAMP()"); 154 149 155 150 if (state) { 156 psStringAppend(&query, " SETstate = '%s'", state);151 psStringAppend(&query, " , state = '%s'", state); 157 152 } 158 153 159 154 if (label) { 160 psStringAppend(&query, " SETlabel = '%s'", label);155 psStringAppend(&query, " , label = '%s'", label); 161 156 } 162 157 163 158 if (code) { 164 psStringAppend(&query, " SETfault = %d", code);159 psStringAppend(&query, " , fault = %d", code); 165 160 } 166 161 … … 301 296 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 302 297 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 298 PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false); 303 299 304 300 // look for "inputs" that need to processed … … 323 319 } 324 320 325 if (!p_psDBRunQuery(config->dbh, query)) { 321 psString chip_magic = ""; 322 psString raw_where = ""; 323 psString chip_where = ""; 324 psString camera_where = ""; 325 psString fake_where = ""; 326 psString warp_where = ""; 327 psString diff_where = ""; 328 psString stack_where = ""; 329 330 if (need_magic) { 331 chip_magic = psStringCopy("\nAND chipRun.magicked"); 332 raw_where = psStringCopy("\nAND rawExp.magicked"); 333 chip_where = psStringCopy("\nAND (distRun.clean OR chipRun.magicked)"); 334 // chipRun must be magicked to allow release camera level masks 335 camera_where = psStringCopy("\nAND (distRun.clean OR chipRun.magicked)"); 336 warp_where = psStringCopy("\nAND (distRun.clean OR warpRun.magicked)"); 337 diff_where = psStringCopy("\nAND (distRun.clean OR diffRun.magicked)"); 338 } 339 340 if (!p_psDBRunQueryF(config->dbh, 341 query, 342 chip_magic, 343 raw_where, 344 chip_where, 345 camera_where, 346 fake_where, 347 warp_where, 348 diff_where, 349 stack_where)) { 326 350 psError(PS_ERR_UNKNOWN, false, "database error"); 327 351 psFree(query); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/disttoolConfig.c
r23352 r23594 47 47 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-stage", 0, "define stage for bundle (required)", NULL); 48 48 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id (required)", 0); 49 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-chip_id", 0, "define chip_id (required for raw stage", 0);50 49 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-outroot", 0, "define output destination (required)", NULL); 51 50 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-clean", 0, "build clean distribution bundle", false); … … 76 75 psMetadataAddS64(pendingcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 77 76 psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-stage", 0, "limit results to runs for stage", NULL); 77 psMetadataAddBool(pendingcomponentArgs, PS_LIST_TAIL, "-need_magic", 0, "magic is needed", false); 78 78 psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-label", 0, "limit results to label", NULL); 79 79 psMetadataAddU64(pendingcomponentArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magicdstool.c
r21433 r23594 40 40 41 41 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); 42 static bool magicDSRunComplete(pxConfig *config );42 static bool magicDSRunComplete(pxConfig *config, bool setmagicked); 43 43 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 44 44 … … 242 242 243 243 // create a new magicRun for this group 244 magicRunRow *run = magicRunRowAlloc(0, exp_id, " run", workdir, "dirty", label, dvodb, registered, 0);244 magicRunRow *run = magicRunRowAlloc(0, exp_id, "new", workdir, "dirty", label, dvodb, registered, 0); 245 245 if (!run) { 246 246 psAbort("failed to alloc magicRun object"); … … 320 320 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 321 321 PXOPT_LOOKUP_STR(outroot, config->args, "-outroot", true, false); 322 323 // optional 322 324 PXOPT_LOOKUP_STR(recoveryroot, config->args, "-recoveryroot", false, false); 323 325 PXOPT_LOOKUP_BOOL(re_place, config->args, "-replace", false); 324 326 PXOPT_LOOKUP_BOOL(remove, config->args, "-remove", false); 325 326 // optional327 327 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 328 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 328 329 329 330 psS64 stage_id = 0, cam_id = 0; … … 337 338 0, // ID 338 339 magic_id, 339 " run", // state340 "new", // state 340 341 stage, 341 342 stage_id, 342 343 cam_id, 344 label, 343 345 outroot, 344 346 recoveryroot, … … 396 398 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 397 399 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 398 // PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");400 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 399 401 400 402 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 526 528 } 527 529 530 static bool 531 setRunMagicked(pxConfig *config, psS64 magic_ds_id) 532 { 533 // first query the magicDSRun to find the stage and the stage_id 534 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64; 535 536 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { 537 psError(PS_ERR_UNKNOWN, false, "database error"); 538 return false; 539 } 540 541 psArray *output = p_psDBFetchResult(config->dbh); 542 if (!output) { 543 psError(PS_ERR_UNKNOWN, false, "database error"); 544 return false; 545 } 546 if (!psArrayLength(output)) { 547 psError(PS_ERR_UNKNOWN, true, "magicDSRun not found for magic_ds_id %" PRId64, magic_ds_id); 548 psFree(output); 549 return false; 550 } 551 if (psArrayLength(output) > 1) { 552 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_ds_id %" PRId64, 553 psArrayLength(output), magic_ds_id); 554 psFree(output); 555 return false; 556 } 557 psMetadata *row = output->data[0]; 558 559 psString stage = psMetadataLookupStr(NULL, row, "stage"); 560 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 561 562 563 // chose the appropriate query based on the stage 564 if (!strcmp(stage, "raw")) { 565 query = "UPDATE rawExp SET magicked = 1 where exp_id = %" PRId64; 566 } else if (!strcmp(stage, "chip")) { 567 query = "UPDATE chipRun SET magicked = 1 where chip_id = %" PRId64; 568 } else if (!strcmp(stage, "warp")) { 569 query = "UPDATE warpRun SET magicked = 1 where warp_id = %" PRId64; 570 } else if (!strcmp(stage, "diff")) { 571 query = "UPDATE diffRun SET magicked = 1 where diff_id = %" PRId64; 572 } else { 573 psError(PS_ERR_UNKNOWN, true, "unexpected value for stage: %s found", stage); 574 psFree(output); 575 return false; 576 } 577 if (!p_psDBRunQueryF(config->dbh, query, stage_id)) { 578 psError(PS_ERR_UNKNOWN, false, "database error"); 579 return false; 580 } 581 psFree(output); 582 583 psU64 affected = psDBAffectedRows(config->dbh); 584 if (affected != 1) { 585 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 586 return false; 587 } 588 589 return true; 590 } 591 528 592 static bool adddestreakedfileMode(pxConfig *config) 529 593 { … … 551 615 552 616 if (setmagicked) { 617 // set the image file's magicked flag 553 618 if (!setMagicked(config, magic_ds_id, component)) { 554 619 psError(PS_ERR_UNKNOWN, false, "setMagicked failed"); 620 if (!psDBRollback(config->dbh)) { 621 psError(PS_ERR_UNKNOWN, false, "database error"); 622 } 555 623 return false; 556 624 } … … 566 634 } 567 635 568 if (!magicDSRunComplete(config )) {636 if (!magicDSRunComplete(config, setmagicked)) { 569 637 // rollback 570 638 if (!psDBRollback(config->dbh)) { … … 591 659 592 660 if (!strcmp(stage, "diff")) { 593 // don't need these ids for diff stage 661 // don't need these ids for diff stage because diff_id is in the magicRun 594 662 *stage_id = 0; 595 663 *cam_id = 0; … … 652 720 } 653 721 654 static bool magicDSRunComplete(pxConfig *config )722 static bool magicDSRunComplete(pxConfig *config, bool setmagicked) 655 723 { 656 724 PS_ASSERT_PTR_NON_NULL(config, false); … … 685 753 psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id"); 686 754 687 // set magicDSRun.state to 'stop' 688 if (!setmagicDSRunState(config, magic_ds_id, "stop")) { 755 // if requested, set stageRun.magicked 756 if (setmagicked && !setRunMagicked(config, magic_ds_id)) { 757 psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64, 758 magic_ds_id); 759 return false; 760 } 761 762 // set magicDSRun.state to 'full' 763 if (!setmagicDSRunState(config, magic_ds_id, "full")) { 689 764 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 690 765 magic_ds_id); … … 795 870 // check that state is a valid string value 796 871 if (!( 797 (strncmp(state, " run", 4) == 0)798 || (strncmp(state, " stop", 5) == 0)872 (strncmp(state, "new", 4) == 0) 873 || (strncmp(state, "full", 5) == 0) 799 874 ) 800 875 ) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magicdstoolConfig.c
r21433 r23594 70 70 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-replace", 0, "use the simple output format", false); 71 71 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-remove", 0, "use the simple output format", false); 72 //psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL);72 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 73 73 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 74 74 … … 88 88 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0); 89 89 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0); 90 // psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0);90 psMetadataAddStr(todestreakArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 91 91 psMetadataAddU64(todestreakArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 92 92 psMetadataAddBool(todestreakArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magictool.c
r21402 r23594 217 217 218 218 // create a new magicRun for this group 219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, " run", workdir, "dirty", label, dvodb, registered, 0);219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, "new", workdir, "dirty", label, dvodb, registered, 0); 220 220 if (!run) { 221 221 psAbort("failed to alloc magicRun object"); … … 538 538 539 539 if (code > 0) { 540 char *query = "UPDATE magicRun SET fault = %d, state = ' stop' WHERE magic_id = %" PRId64;540 char *query = "UPDATE magicRun SET fault = %d, state = 'full' WHERE magic_id = %" PRId64; 541 541 if (!p_psDBRunQueryF(config->dbh, query, code, magic_id)) { 542 542 psError(PS_ERR_UNKNOWN, false, … … 1088 1088 } 1089 1089 1090 // Set to " run"1090 // Set to "new" 1091 1091 { 1092 1092 psString query = psStringCopy("UPDATE magicRun JOIN magicMask USING(magic_id) " 1093 "SET magicRun.state = ' run' WHERE magicMask.fault != 0");1093 "SET magicRun.state = 'new' WHERE magicMask.fault != 0"); 1094 1094 1095 1095 if (psListLength(where->list)) { … … 1481 1481 // check that state is a valid string value 1482 1482 if (!( 1483 (strncmp(state, " run", 4) == 0)1484 || (strncmp(state, " stop", 5) == 0)1483 (strncmp(state, "new", 4) == 0) 1484 || (strncmp(state, "full", 5) == 0) 1485 1485 || (strncmp(state, "reg", 4) == 0) 1486 1486 ) -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxcam.c
r21402 r23594 42 42 psMetadataAddStr(md, PS_LIST_TAIL, "-comment", 0, "search by comment", NULL); 43 43 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL);45 44 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 46 45 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); … … 77 76 bool pxcamGetSearchArgs (pxConfig *config, psMetadata *where) { 78 77 79 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 80 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 81 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 82 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 83 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 85 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 86 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 87 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 88 PXOPT_COPY_STR(config->args, where, "-comment", "rawExp.comment", "LIKE"); 89 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 90 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 91 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 92 PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">="); 93 PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<"); 94 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 95 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 96 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 97 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 98 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 99 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 100 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 101 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 102 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 103 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 104 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 105 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 106 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 107 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 108 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 109 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 110 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 111 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 112 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 113 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 114 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 115 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 116 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 117 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 118 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 78 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 79 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 80 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 81 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 82 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 83 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 85 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 86 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 87 PXOPT_COPY_STR(config->args, where, "-comment", "rawExp.comment", "LIKE"); 88 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 89 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 90 PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 91 PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 92 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 93 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 94 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 95 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 96 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 97 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 98 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 99 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 100 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 101 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 102 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 103 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 104 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 105 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 106 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 107 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 108 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 109 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 110 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 111 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 112 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 113 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 114 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 115 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 116 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 119 117 120 118 return true; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxchip.c
r21402 r23594 31 31 bool pxchipSetSearchArgs (psMetadata *md) { 32 32 33 // psMetadataAddStr(md, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 34 // psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 35 33 36 // XXX need to allow multiple exp_ids 34 37 psMetadataAddS64(md, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 35 38 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 36 // psMetadataAddStr(md, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL);37 39 psMetadataAddStr(md, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 38 40 psMetadataAddStr(md, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); … … 42 44 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 43 45 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 // psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL);45 46 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 46 47 psMetadataAddF32(md, PS_LIST_TAIL, "-airmass_min", 0, "search by min airmass", NAN); … … 128 129 } 129 130 130 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state )131 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked) 131 132 { 132 133 PS_ASSERT_PTR_NON_NULL(config, false); … … 139 140 } 140 141 141 char *query = "UPDATE chipRun SET state = '%s' WHERE chip_id = %" PRId64;142 if (!p_psDBRunQueryF(config->dbh, query, state, chip_id)) {142 char *query = "UPDATE chipRun SET state = '%s', magicked = %d WHERE chip_id = %" PRId64; 143 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, chip_id)) { 143 144 psError(PS_ERR_UNKNOWN, false, 144 145 "failed to change state for chip_id %" PRId64, chip_id); … … 158 159 if (!pxIsValidState(state)) { 159 160 psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state); 161 return false; 162 } 163 164 if (!strcmp(state, "full")) { 165 // There are states that need to be met for a run to be set to full that we don't 166 // check here. 167 // for example all of the run's Imfiles must have chipProcessedImfile.data_state == "full" 168 // chipRun.magicked = (SUM(!chipProcessedImfile.magicked) = 0) 169 // so don't do allow setting the state to full 170 psError(PS_ERR_UNKNOWN, true, "cannot use -updaterun so set chipRun state to full"); 160 171 return false; 161 172 } … … 253 264 dvodb, 254 265 tess_id, 255 end_stage) 266 end_stage, 267 0 // magicked 268 ) 256 269 ) { 257 270 if (!psDBRollback(config->dbh)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxchip.h
r19324 r23594 25 25 #include "pxtools.h" 26 26 27 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state );27 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked); 28 28 bool pxchipRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 29 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxerrors.c
r17611 r23594 24 24 #include "pxtools.h" 25 25 26 psExit pxerrorGetExitStatus () {26 psExit pxerrorGetExitStatus(void) { 27 27 28 28 psErrorCode err = psErrorCodeLast (); … … 38 38 default: 39 39 return PS_EXIT_UNKNOWN_ERROR; 40 } 40 } 41 41 return PS_EXIT_UNKNOWN_ERROR; 42 42 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxtools.h
r18561 r23594 53 53 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code); 54 54 55 psExit pxerrorGetExitStatus ();55 psExit pxerrorGetExitStatus(void); 56 56 57 57 void pxUsage(FILE *stream, int argc, char **argv, const char *modeName, psMetadata *argSet); … … 303 303 #define PXOPT_ADD_WHERE_BOOL(name) \ 304 304 { \ 305 bool value = false; \305 bool value = false; \ 306 306 bool status = false; \ 307 307 if ((value = psMetadataLookupBool(&status, config->args, "-" #name))) { \ … … 370 370 } 371 371 372 #define PXOPT_ADD_WHERE_BOOL_ALIAS(flag,name) \372 #define PXOPT_ADD_WHERE_BOOL_ALIAS(flag,name) \ 373 373 { \ 374 374 bool value = 0; \ 375 375 bool status = false; \ 376 if ((value = psMetadataLookupBool(&status, config->args, flag))) { \376 if ((value = psMetadataLookupBool(&status, config->args, flag))) { \ 377 377 if (!psMetadataAddBOOL(config->where, PS_LIST_TAIL, name, 0, "==", value)) { \ 378 378 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 383 383 } 384 384 385 #define PXOPT_ADD_WHERE_S16_ALIAS(flag,name) \385 #define PXOPT_ADD_WHERE_S16_ALIAS(flag,name) \ 386 386 { \ 387 387 psS16 s16 = 0; \ 388 388 bool status = false; \ 389 if ((s16= psMetadataLookupS16(&status, config->args, flag))) { \389 if ((s16= psMetadataLookupS16(&status, config->args, flag))) { \ 390 390 if (!psMetadataAddS16(config->where, PS_LIST_TAIL, name, 0, "==", s16)) { \ 391 391 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 396 396 } 397 397 398 #define PXOPT_ADD_WHERE_S32_ALIAS(flag,name) \398 #define PXOPT_ADD_WHERE_S32_ALIAS(flag,name) \ 399 399 { \ 400 400 psS32 s32 = 0; \ 401 401 bool status = false; \ 402 if ((s32= psMetadataLookupS32(&status, config->args, flag))) { \402 if ((s32= psMetadataLookupS32(&status, config->args, flag))) { \ 403 403 if (!psMetadataAddS32(config->where, PS_LIST_TAIL, name, 0, "==", s32)) { \ 404 404 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 409 409 } 410 410 411 #define PXOPT_ADD_WHERE_S64_ALIAS(flag,name) \411 #define PXOPT_ADD_WHERE_S64_ALIAS(flag,name) \ 412 412 { \ 413 413 psS64 s64 = 0; \ 414 414 bool status = false; \ 415 if ((s64= psMetadataLookupS64(&status, config->args, flag))) { \415 if ((s64= psMetadataLookupS64(&status, config->args, flag))) { \ 416 416 if (!psMetadataAddS64(config->where, PS_LIST_TAIL, name, 0, "==", s64)) { \ 417 417 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 422 422 } 423 423 424 #define PXOPT_ADD_WHERE_F32_ALIAS(flag,name) \424 #define PXOPT_ADD_WHERE_F32_ALIAS(flag,name) \ 425 425 { \ 426 426 psF32 var = 0; \ 427 427 bool status = false; \ 428 if ((var = psMetadataLookupF32(&status, config->args, flag))) { \428 if ((var = psMetadataLookupF32(&status, config->args, flag))) { \ 429 429 if (!isnan(var)) { \ 430 430 if (!psMetadataAddF32(config->where, PS_LIST_TAIL, name, 0, "==", var)) { \ … … 437 437 } 438 438 439 #define PXOPT_ADD_WHERE_F64_ALIAS(flag,name) \439 #define PXOPT_ADD_WHERE_F64_ALIAS(flag,name) \ 440 440 { \ 441 441 psF64 var = 0; \ 442 442 bool status = false; \ 443 if ((var = psMetadataLookupF64(&status, config->args, flag))) { \443 if ((var = psMetadataLookupF64(&status, config->args, flag))) { \ 444 444 if (!isnan(var)) { \ 445 445 if (!psMetadataAddF64(config->where, PS_LIST_TAIL, name, 0, "==", var)) { \ -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxwarp.c
r23352 r23594 28 28 #include "pxtools.h" 29 29 #include "pxwarp.h" 30 31 bool pxwarpSetSearchArgs (psMetadata *md) { 32 psMetadataAddS64(md, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 33 psMetadataAddS64(md, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 34 psMetadataAddS64(md, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 35 psMetadataAddS64(md, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 36 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 37 psMetadataAddStr(md, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 38 psMetadataAddStr(md, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 39 psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 40 psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 41 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 42 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 43 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 45 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_min", 0, "search by min airmass", NAN); 46 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_max", 0, "search by max airmass", NAN); 47 psMetadataAddF64(md, PS_LIST_TAIL, "-ra_min", 0, "search by min", NAN); 48 psMetadataAddF64(md, PS_LIST_TAIL, "-ra_max", 0, "search by max", NAN); 49 psMetadataAddF64(md, PS_LIST_TAIL, "-decl_min", 0, "search by min", NAN); 50 psMetadataAddF64(md, PS_LIST_TAIL, "-decl_max", 0, "search by max", NAN); 51 psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_min", 0, "search by min", NAN); 52 psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_max", 0, "search by max", NAN); 53 psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "search by max fraction of saturated pixels", NAN); 54 psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "search by min fraction of saturated pixels", NAN); 55 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_min", 0, "search by max", NAN); 56 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_max", 0, "search by max", NAN); 57 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_min", 0, "search by max", NAN); 58 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_max", 0, "search by max", NAN); 59 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "search by max", NAN); 60 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "search by max", NAN); 61 psMetadataAddF64(md, PS_LIST_TAIL, "-alt_min", 0, "search by min", NAN); 62 psMetadataAddF64(md, PS_LIST_TAIL, "-alt_max", 0, "search by max", NAN); 63 psMetadataAddF64(md, PS_LIST_TAIL, "-az_min", 0, "search by min", NAN); 64 psMetadataAddF64(md, PS_LIST_TAIL, "-az_max", 0, "search by max", NAN); 65 psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_min", 0, "search by min ccd tempature", NAN); 66 psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_max", 0, "search by max ccd tempature", NAN); 67 psMetadataAddF64(md, PS_LIST_TAIL, "-posang_min", 0, "search by min rotator position angle", NAN); 68 psMetadataAddF64(md, PS_LIST_TAIL, "-posang_max", 0, "search by max rotator position angle", NAN); 69 psMetadataAddStr(md, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 70 psMetadataAddF32(md, PS_LIST_TAIL, "-solang_min", 0, "search by min solar angle", NAN); 71 psMetadataAddF32(md, PS_LIST_TAIL, "-solang_max", 0, "search by max solar angle", NAN); 72 return true; 73 } 74 75 bool pxwarpGetSearchArgs (pxConfig *config, psMetadata *where) { 76 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 77 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 78 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 79 PXOPT_COPY_S64(config->args, where, "-exp_id", "newExp.exp_id", "=="); 80 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 81 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 82 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 83 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 85 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 86 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 87 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 88 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 89 PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 90 PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 91 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 92 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 93 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 94 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 95 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 96 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 97 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 98 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 99 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 100 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 101 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 102 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 103 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 104 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 105 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 106 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 107 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 108 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 109 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 110 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 111 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 112 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 113 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 114 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 115 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 116 return true; 117 } 30 118 31 119 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state) … … 147 235 tess_id, 148 236 end_stage, 149 NULL // registered 237 NULL, // registered 238 0 // magicked zero when created will get updated when warpRun goes to 'full' 150 239 )) { 151 240 psError(PS_ERR_UNKNOWN, false, "database error"); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxwarp.h
r18029 r23594 25 25 #include "pxtools.h" 26 26 27 bool pxwarpGetSearchArgs (pxConfig *config, psMetadata *where); 28 bool pxwarpSetSearchArgs (psMetadata *md); 29 27 30 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state); 28 31 bool pxwarpRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztool.c
r21479 r23594 44 44 45 45 static bool clearcommonfaultsMode(pxConfig *config); 46 static bool toadvanceMode(pxConfig *config); 46 47 static bool advanceMode(pxConfig *config); 47 48 48 static bool copydoneCompleteExp(pxConfig *config);49 // static bool copydoneCompleteExp(pxConfig *config); 49 50 static psArray *pzGetPendingCameras(pxConfig *config); 50 51 static psArray *pzArrayZip(psArray *arraySet, psS64 limit); … … 80 81 MODECASE(PZTOOL_MODE_REVERTCOPIED, revertcopiedMode); 81 82 MODECASE(PZTOOL_MODE_CLEARCOMMONFAULTS, clearcommonfaultsMode); 83 MODECASE(PZTOOL_MODE_TOADVANCE, toadvanceMode); 82 84 MODECASE(PZTOOL_MODE_ADVANCE, advanceMode); 83 85 default: … … 403 405 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 404 406 405 // NOTE : the rest of the command-line args are parsed in copydoneCompleteExp406 407 407 // start a transaction early so it will contain any row level locks 408 408 if (!psDBTransaction(config->dbh)) { … … 463 463 } 464 464 465 #ifdef notdef466 // we've changed to use -advance instead467 if (!copydoneCompleteExp(config)) {468 // rollback469 if (!psDBRollback(config->dbh)) {470 psError(PS_ERR_UNKNOWN, false, "database error");471 }472 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed");473 return false;474 }475 #endif476 465 // point of no return 477 466 if (!psDBCommit(config->dbh)) { … … 487 476 } 488 477 489 static bool copydoneCompleteExp(pxConfig *config) 490 { 491 // THIS FUNCTION MUST BE INVOKED FROM INSIDE A TRANSACTION!!! 492 493 PS_ASSERT_PTR_NON_NULL(config, false); 494 495 // XXX this is an ugly hack! 496 // we are passing exp level info to a imfile level mode (-copydone) 497 // these options are thrown away unless we just -copydone'd the last imfile 498 // in an exp. 499 500 // optional 501 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 502 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 503 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false); 504 PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false); 505 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 478 static bool toadvanceMode(pxConfig *config) 479 { 480 PS_ASSERT_PTR_NON_NULL(config, false); 481 482 // optional args 483 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 506 484 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 507 485 … … 517 495 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 518 496 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 519 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 497 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 498 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 520 499 521 500 if (psListLength(where->list)) { … … 525 504 } 526 505 psFree(where); 506 527 507 528 508 // treat limit == 0 as "no limit" … … 552 532 } 553 533 554 for (long i = 0; i < psArrayLength(output); i++) { 555 psMetadata *row = output->data[i]; 556 557 pzDownloadExpRow *doneExp = pzDownloadExpObjectFromMetadata(row); 558 if (!doneExp) { 559 psError(PS_ERR_UNKNOWN, false, "pzDownloadExpObjectFromMetadata() failed"); 560 psFree(doneExp); 561 psFree(output); 562 return false; 563 } 564 565 if (!newExpInsert(config->dbh, 566 0x0, // exp_id 567 doneExp->exp_name, // tmp_exp_name 568 doneExp->camera, // tmp_camera 569 doneExp->telescope, // tmp_telescope 570 "run", // state 571 workdir, // workdir 572 "dirty", // workdir state 573 NULL, // reduction class 574 dvodb, // dvodb 575 tess_id, // tess_id 576 end_stage, // end_stage 577 label, 578 NULL // epoch 579 ) 534 if (!ippdbPrintMetadatas(stdout, output, "toadvance", !simple)) { 535 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 536 psFree(output); 537 return false; 538 } 539 540 psFree(output); 541 542 return true; 543 } 544 545 static bool advanceMode(pxConfig *config) 546 { 547 PS_ASSERT_PTR_NON_NULL(config, false); 548 549 // required 550 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 551 PXOPT_LOOKUP_STR(inst, config->args, "-inst", true, false); 552 PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", true, false); 553 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 554 555 // optional 556 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 557 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false); 558 PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false); 559 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 560 561 // start a transaction so it's all rows or nothing 562 if (!psDBTransaction(config->dbh)) { 563 psError(PS_ERR_UNKNOWN, false, "database error"); 564 return false; 565 } 566 567 if (!newExpInsert(config->dbh, 568 0x0, // exp_id 569 exp_name, // tmp_exp_name 570 inst, // tmp_camera 571 telescope, // tmp_telescope 572 "run", // state 573 workdir, // workdir 574 "dirty", // workdir state 575 NULL, // reduction class 576 dvodb, // dvodb 577 tess_id, // tess_id 578 end_stage, // end_stage 579 label, // label 580 NULL // epoch 581 ) 580 582 ) { 581 583 psError(PS_ERR_UNKNOWN, false, "database error"); 582 psFree(doneExp);583 psFree(output);584 584 return false; 585 585 } … … 592 592 "INSERT INTO newImfile" 593 593 " SElECT" 594 " %" PRId64 "," // exp_id594 " %" PRId64 "," // exp_id 595 595 " pzDownloadImfile.class_id," // tmp_class_id 596 " pzDownloadImfile.uri," // uri597 " NULL" // epoch596 " pzDownloadImfile.uri," // uri 597 " NULL" // epoch 598 598 " FROM pzDownloadImfile" 599 599 " WHERE" … … 602 602 " AND pzDownloadImfile.telescope = '%s'"; 603 603 604 if (!p_psDBRunQueryF(config->dbh, query, exp_id, doneExp->exp_name, doneExp->camera, doneExp->telescope)) { 605 psError(PS_ERR_UNKNOWN, false, "database error"); 606 psFree(doneExp); 607 psFree(output); 608 return false; 609 } 610 611 // sanity check: we should have inserted at least one row 612 psU64 affected = psDBAffectedRows(config->dbh); 613 if (psDBAffectedRows(config->dbh) < 1) { 614 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 615 psFree(doneExp); 616 psFree(output); 617 return false; 618 } 619 } 620 621 // set pzDownloadExp.state to 'stop' 622 if (!pzDownloadExpSetState(config, doneExp->exp_name, doneExp->camera, doneExp->telescope, "stop")) { 623 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %s:%s:%s", doneExp->exp_name, doneExp->camera, doneExp->telescope); 624 psFree(doneExp); 625 psFree(output); 604 if (!p_psDBRunQueryF(config->dbh, query, exp_id, exp_name, inst, telescope)) { 605 psError(PS_ERR_UNKNOWN, false, "database error"); 626 606 return false; 627 } 628 629 psFree(doneExp); 630 } 631 632 psFree(output); 607 } 608 609 // sanity check: we should have inserted at least one row 610 psU64 affected = psDBAffectedRows(config->dbh); 611 if (psDBAffectedRows(config->dbh) < 1) { 612 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 613 return false; 614 } 615 } 616 617 // set pzDownloadExp.state to 'stop' 618 if (!pzDownloadExpSetState(config, exp_name, inst, telescope, "stop")) { 619 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %s:%s:%s", exp_name, inst, telescope); 620 return false; 621 } 622 623 // point of no return 624 if (!psDBCommit(config->dbh)) { 625 // rollback 626 if (!psDBRollback(config->dbh)) { 627 psError(PS_ERR_UNKNOWN, false, "database error"); 628 } 629 psError(PS_ERR_UNKNOWN, false, "database error"); 630 return false; 631 } 632 633 633 634 634 return true; … … 872 872 } 873 873 874 static bool advanceMode(pxConfig *config)875 {876 PS_ASSERT_PTR_NON_NULL(config, false);877 878 // NOTE : the command-line args are parsed in copydoneCompleteExp879 880 // start a transaction so it's all rows or nothing881 if (!psDBTransaction(config->dbh)) {882 psError(PS_ERR_UNKNOWN, false, "database error");883 return false;884 }885 886 if (!copydoneCompleteExp(config)) {887 // rollback888 if (!psDBRollback(config->dbh)) {889 psError(PS_ERR_UNKNOWN, false, "database error");890 }891 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed");892 return false;893 }894 895 // point of no return896 if (!psDBCommit(config->dbh)) {897 // rollback898 if (!psDBRollback(config->dbh)) {899 psError(PS_ERR_UNKNOWN, false, "database error");900 }901 psError(PS_ERR_UNKNOWN, false, "database error");902 return false;903 }904 905 906 return true;907 }908 909 874 910 875 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state) -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztool.h
r18314 r23594 35 35 PZTOOL_MODE_REVERTCOPIED, 36 36 PZTOOL_MODE_CLEARCOMMONFAULTS, 37 PZTOOL_MODE_TOADVANCE, 37 38 PZTOOL_MODE_ADVANCE 38 39 } pztoolMode; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztoolConfig.c
r21479 r23594 97 97 psMetadataAddS16(copydoneArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 98 98 psMetadataAddBool(copydoneArgs, PS_LIST_TAIL, "-row_lock", 0, "lock pzDownImfile rows while advancing an exposure", false); 99 // XXX: remove this once advance is fixed 100 psMetadataAddU64(copydoneArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 99 101 100 102 // -copied … … 129 131 // -clearcommonfaults 130 132 psMetadata *clearcommonfaultsArgs = psMetadataAlloc(); 133 // 134 // -toadvance 135 psMetadata *toadvanceArgs = psMetadataAlloc(); 136 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 137 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); 138 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID", NULL); 139 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 140 psMetadataAddBool(toadvanceArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 141 psMetadataAddU64(toadvanceArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 131 142 132 143 // -advance 133 144 psMetadata *advanceArgs = psMetadataAlloc(); 134 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 135 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); 136 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID", NULL); 137 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-workdir", 0, "define the \"default\" workdir for this exposure", NULL); 138 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-dvodb", 0, "define the dvodb for the next processing step", NULL); 139 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-tess_id", 0, "define the tess_id for the next processing step", NULL); 140 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-end_stage", 0, "define the end goal processing step", NULL); 141 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 142 psMetadataAddU64(advanceArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 145 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID (required)", NULL); 146 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID (required)", NULL); 147 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID (required)", NULL); 148 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-workdir", 0, "define the \"default\" workdir for this exposure (required)", NULL); 149 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-dvodb", 0, "define the dvodb for the next processing step", NULL); 150 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-tess_id", 0, "define the tess_id for the next processing step", NULL); 151 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-end_stage", 0, "define the end goal processing step", NULL); 152 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 143 153 144 154 psMetadata *argSets = psMetadataAlloc(); … … 155 165 PXOPT_ADD_MODE("-revertcopied", "", PZTOOL_MODE_REVERTCOPIED,revertcopiedArgs); 156 166 PXOPT_ADD_MODE("-clearcommonfaults","", PZTOOL_MODE_CLEARCOMMONFAULTS,clearcommonfaultsArgs); 167 PXOPT_ADD_MODE("-toadvance", "", PZTOOL_MODE_TOADVANCE, toadvanceArgs); 157 168 PXOPT_ADD_MODE("-advance", "", PZTOOL_MODE_ADVANCE, advanceArgs); 158 169 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.c
r23352 r23594 319 319 320 320 psMetadata *where = psMetadataAlloc(); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 324 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 325 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 324 326 325 327 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 407 409 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 408 410 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 411 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 412 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 409 413 410 414 psString query = pxDataGet("regtool_revertprocessedimfile.sql"); … … 419 423 psStringAppend(&query, " AND %s", whereClause); 420 424 psFree(whereClause); 425 } else { 426 psFree(where); 427 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 428 return false; 421 429 } 422 430 psFree(where); … … 429 437 psFree(query); 430 438 431 if (psDBAffectedRows(config->dbh) < 1) { 432 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 433 return false; 434 } 439 int numUpdated = psDBAffectedRows(config->dbh); 440 441 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawImfile", numUpdated); 435 442 436 443 return true; … … 441 448 { 442 449 PS_ASSERT_PTR_NON_NULL(config, false); 450 451 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 452 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 453 454 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 455 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 456 457 if ((code == INT16_MAX) && !isfinite(user_1)) { 458 psError(PS_ERR_UNKNOWN, false, "one of -code or -user_1 must be selected"); 459 return false; 460 } 461 if ((code != INT16_MAX) && isfinite(user_1)) { 462 psError(PS_ERR_UNKNOWN, false, "only one of -code or -user_1 must be selected"); 463 return false; 464 } 443 465 444 466 psMetadata *where = psMetadataAlloc(); … … 446 468 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 447 469 448 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 449 450 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 451 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 452 psFree (where); 453 return false; 470 if (code != INT16_MAX) { 471 // this is fairly dangerous : can set all if the where is not set... 472 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 473 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 474 psFree (where); 475 return false; 476 } 477 } 478 479 if (isfinite(user_1)) { 480 psString query = pxDataGet("regtool_updateprocessedimfile.sql"); 481 if (!query) { 482 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 483 return false; 484 } 485 486 if (!p_psDBRunQueryF(config->dbh, query, user_1, exp_id, class_id)) { 487 psError(PS_ERR_UNKNOWN, false, "database error"); 488 psFree(query); 489 return false; 490 } 491 psFree(query); 454 492 } 455 493 psFree (where); … … 764 802 hostname, 765 803 code, 766 NULL 804 NULL, 805 0 767 806 )) { 768 807 // rollback … … 806 845 exp_id, 807 846 workdir, 808 label,847 label, 809 848 reduction, 810 849 NULL, // expgroup … … 957 996 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 958 997 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 998 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 999 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 959 1000 960 1001 psString query = pxDataGet("regtool_revertprocessedexp.sql"); … … 968 1009 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); 969 1010 psStringAppend(&query, " AND %s", whereClause); 1011 psFree(whereClause); 1012 } else { 970 1013 psFree(where); 971 psFree(whereClause); 1014 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 1015 return false; 972 1016 } 973 1017 psFree(where); … … 980 1024 psFree(query); 981 1025 982 if (psDBAffectedRows(config->dbh) < 1) { 983 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 984 return false; 985 } 1026 int numUpdated = psDBAffectedRows(config->dbh); 1027 1028 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawExp", numUpdated); 986 1029 987 1030 return true; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtoolConfig.c
r23352 r23594 129 129 ADD_OPT(Str, processedimfileArgs, "-exp_name", "search by exposure name", NULL); 130 130 ADD_OPT(Str, processedimfileArgs, "-class_id", "search by class ID", NULL); 131 ADD_OPT(Time, processedimfileArgs, "-dateobs_begin", "search for exposures by time (>=)", NULL); 132 ADD_OPT(Time, processedimfileArgs, "-dateobs_end", "search for exposures by time (<)", NULL); 131 133 ADD_OPT(U64, processedimfileArgs, "-limit", "limit result set to N items", 0); 132 134 ADD_OPT(Bool, processedimfileArgs, "-faulted", "only return imfiles with a fault status set", false); … … 135 137 // -revertprocessedimfile 136 138 psMetadata *revertprocessedimfileArgs = psMetadataAlloc(); 137 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id", "search by exposure ID (required)", 0);139 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id", "search by exposure ID", 0); 138 140 ADD_OPT(Str, revertprocessedimfileArgs, "-tmp_class_id", "searcy by temp. class ID", NULL); 139 141 ADD_OPT(Str, revertprocessedimfileArgs, "-class_id", "search by class ID", NULL); 140 142 ADD_OPT(S16, revertprocessedimfileArgs, "-code", "search by fault code", 0); 143 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_begin", "search by exposure ID", 0); 144 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_end", "search by exposure ID", 0); 141 145 142 146 // -updateprocessedimfile … … 144 148 ADD_OPT(S64, updateprocessedimfileArgs, "-exp_id", "search by exposure ID", 0); 145 149 ADD_OPT(Str, updateprocessedimfileArgs, "-class_id", "search by class ID", NULL); 146 ADD_OPT(S16, updateprocessedimfileArgs, "-code", "set fault code (required)", INT16_MAX); 150 ADD_OPT(F64, updateprocessedimfileArgs, "-user_1", "set user stat (1)", NAN); 151 ADD_OPT(S16, updateprocessedimfileArgs, "-code", "set fault code", INT16_MAX); 147 152 148 153 // -pendingexp … … 270 275 // -revertprocessedexp 271 276 psMetadata *revertprocessedexpArgs = psMetadataAlloc(); 272 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID (required)", 0);277 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 273 278 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 279 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_begin", 0, "search by exposure ID", 0); 280 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_end", 0, "search by exposure ID", 0); 274 281 275 282 // -updatedprocessedexp -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptool.c
r23352 r23594 157 157 tess_id, 158 158 end_stage, 159 registered 159 registered, 160 false // magicked 160 161 ); 161 162 if (!warpRun) { … … 190 191 191 192 psMetadata *where = psMetadataAlloc(); 192 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 193 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 194 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 195 PXOPT_COPY_S64(config->args, where, "-exp_id", "newExp.exp_id", "=="); 196 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 197 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 198 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 199 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 200 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 201 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 202 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 203 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 204 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 205 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 206 PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">="); 207 PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<"); 208 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 209 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 210 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 211 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 212 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 213 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 214 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 215 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 216 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 217 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 218 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 219 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 220 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 221 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 222 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 223 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 224 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 225 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 226 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 227 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 228 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 229 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 230 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 231 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 232 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 233 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 193 pxwarpGetSearchArgs (config, where); 194 PXOPT_COPY_STR(config->args, where, "-reduction", "fakeRun.reduction", "=="); 195 PXOPT_COPY_STR(config->args, where, "-label", "fakeRun.label", "=="); 234 196 235 197 if (!psListLength(where->list) && … … 337 299 338 300 psMetadata *where = psMetadataAlloc(); 339 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 340 PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "=="); 341 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 342 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 343 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 344 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 345 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 346 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 347 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 348 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 349 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 350 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 351 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 352 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 353 PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">="); 354 PXOPT_COPY_F32(config->args, where, "-airmass_max", "airmass", "<"); 355 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 356 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 357 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 358 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 359 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 360 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 361 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 362 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 363 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 364 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 365 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 366 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 367 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 368 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 369 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 370 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 371 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 372 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 373 PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 374 PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 375 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 376 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 377 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 378 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 379 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 301 pxwarpGetSearchArgs (config, where); 302 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "=="); 303 PXOPT_COPY_STR(config->args, where, "-reduction", "warpRun.reduction", "=="); 304 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 305 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 380 306 381 307 if (!psListLength(where->list) … … 387 313 } 388 314 389 PXOPT_LOOKUP_STR(state, config->args, "-s tate", false, false);390 PXOPT_LOOKUP_STR(label, config->args, "- label", false, false);315 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 316 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 391 317 392 318 if ((!state) && (!label)) { … … 934 860 PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false); 935 861 PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false); 862 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 936 863 937 864 // default values … … 965 892 !accept, 966 893 code, 967 0 // magic_ds_id894 magicked 968 895 )) { 969 896 if (!psDBRollback(config->dbh)) { … … 995 922 PS_ASSERT_PTR_NON_NULL(config, false); 996 923 997 // XXX this SQL has not been broken out to into seperate files as the MYSQL 998 // < 5 & MYSQL 5 versions need to be kept in sync 999 1000 #undef MYSQL5 1001 #if MYSQL5 1002 // XXX at MySQL 4.1.21 (probably all of 4.1.x) chokes and dies on this 1003 // statement as it thinks it is trying to select from the table being 1004 // updated. The 4.1 manual says that nested sub-queries are explicited 1005 // allowed to do this with update statements as a temporary table is 1006 // created so that you are not actually selecting from the table you are 1007 // modifying. 1008 char *query = 1009 "UPDATE warpRun\n" 1010 " SET warpRun.state = 'stop'\n" 1011 " WHERE\n" 1012 " warpRun.warp_id =\n" 1013 " (SELECT DISTINCT\n" 1014 " warp_id\n" 1015 " FROM\n" 1016 " (SELECT DISTINCT\n" 1017 " warpRun.warp_id,\n" 1018 " warpSkyCellMap.warp_id as foo,\n" 1019 " warpSkyfile.warp_id as bar\n" 1020 " FROM warpRun\n" 1021 " JOIN warpSkyCellMap\n" 1022 " USING(warp_id)\n" 1023 " LEFT JOIN warpSkyfile\n" 1024 " USING(warp_id, skycell_id, tess_id)\n" 1025 " WHERE\n" 1026 " warpRun.state = 'new'\n" 1027 " GROUP BY\n" 1028 " warpRun.warp_id\n" 1029 " HAVING\n" 1030 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n" 1031 " ) as Foo\n" 1032 " )\n"; 924 psString query = pxDataGet("warptool_finished_run_select.sql"); 925 if (!query) { 926 psError(PXTOOLS_ERR_DATA, false, "failed to retrieve SQL statement"); 927 return false; 928 } 1033 929 1034 930 if (!p_psDBRunQuery(config->dbh, query)) { 1035 931 psError(PS_ERR_UNKNOWN, false, "database error"); 1036 return false; 1037 } 1038 #else // if MYSQL5 1039 { 1040 char *query = 1041 "CREATE TEMPORARY TABLE finished\n" 1042 " (warp_id INT, PRIMARY KEY(warp_id)) ENGINE=MEMORY\n"; 1043 1044 if (!p_psDBRunQuery(config->dbh, query)) { 1045 psError(PS_ERR_UNKNOWN, false, "database error"); 1046 return false; 1047 } 1048 } 1049 1050 { 1051 char *query = 1052 "INSERT INTO finished\n" 1053 " SELECT\n" 1054 " warp_id\n" 1055 " FROM\n" 1056 " (SELECT DISTINCT\n" 1057 " warpRun.warp_id,\n" 1058 " warpSkyCellMap.warp_id as foo,\n" 1059 " warpSkyfile.warp_id as bar\n" 1060 " FROM warpRun\n" 1061 " JOIN warpSkyCellMap\n" 1062 " USING(warp_id)\n" 1063 " LEFT JOIN warpSkyfile\n" 1064 " USING(warp_id, skycell_id)\n" 1065 " WHERE\n" 1066 " warpRun.state = 'new'\n" 1067 " GROUP BY\n" 1068 " warpRun.warp_id\n" 1069 " HAVING\n" 1070 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n" 1071 " ) as Foo \n"; 1072 1073 if (!p_psDBRunQuery(config->dbh, query)) { 1074 psError(PS_ERR_UNKNOWN, false, "database error"); 1075 return false; 1076 } 1077 } 1078 1079 { 1080 char *query = 1081 "UPDATE warpRun\n" 1082 " SET warpRun.state = 'full'\n" 1083 " WHERE\n" 1084 " warpRun.warp_id =\n" 1085 " (SELECT DISTINCT\n" 1086 " warp_id\n" 1087 " FROM finished\n" 1088 " )\n"; 1089 1090 if (!p_psDBRunQuery(config->dbh, query)) { 1091 psError(PS_ERR_UNKNOWN, false, "database error"); 1092 return false; 1093 } 1094 } 1095 #endif // if MYSQL5 932 psFree(query); 933 return false; 934 } 935 psFree(query); 936 937 psArray *output = p_psDBFetchResult(config->dbh); 938 if (!output) { 939 psError(PS_ERR_UNKNOWN, false, "database error"); 940 return false; 941 } 942 if (!psArrayLength(output)) { 943 psTrace("warptool", PS_LOG_INFO, "no rows found"); 944 psFree(output); 945 return true; 946 } 947 948 query = pxDataGet("warptool_finish_run.sql"); 949 for (long i = 0; i < psArrayLength(output); i++) { 950 psMetadata *row = output->data[i]; 951 952 bool status; 953 psS64 warp_id = psMetadataLookupS64(&status, row, "warp_id"); 954 if (!status) { 955 psError(PS_ERR_UNKNOWN, false, "failed to look up value for warp_id"); 956 psFree(output); 957 psFree(query); 958 return false; 959 } 960 psS32 magicked = psMetadataLookupS64(&status, row, "magicked"); 961 if (!status) { 962 psError(PS_ERR_UNKNOWN, false, "failed to look up value for magicked"); 963 psFree(output); 964 psFree(query); 965 return false; 966 } 967 if (!p_psDBRunQueryF(config->dbh, query, magicked, warp_id)) { 968 psError(PS_ERR_UNKNOWN, false, "database error"); 969 psFree(output); 970 psFree(query); 971 return false; 972 } 973 974 psS64 numUpdated = psDBAffectedRows(config->dbh); 975 976 if (numUpdated != 1) { 977 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 978 psFree(query); 979 psFree(output); 980 return false; 981 } 982 } 983 psFree(output); 984 psFree(query); 1096 985 1097 986 return true; … … 1181 1070 1182 1071 psMetadata *where = psMetadataAlloc(); 1183 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1072 pxwarpGetSearchArgs (config, where); 1073 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1184 1074 PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1185 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1186 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 1187 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1188 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1189 1190 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1191 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 1192 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 1193 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 1194 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 1195 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 1196 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 1197 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 1198 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 1199 PXOPT_COPY_STR(config->args, where, "-reduction", "rawExp.reduction", "=="); 1200 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 1201 1202 PXOPT_COPY_F32(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 1203 PXOPT_COPY_F32(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 1204 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 1205 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 1206 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 1207 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 1208 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 1209 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 1210 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 1211 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 1212 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 1213 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 1214 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 1215 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 1216 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 1217 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 1218 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 1219 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 1220 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 1221 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 1222 PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 1223 PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 1224 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 1225 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 1226 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 1227 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 1228 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 1229 PXOPT_COPY_S16(config->args, where, "-code", "warpSkyfile.fault", "=="); 1075 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1076 PXOPT_COPY_STR(config->args, where, "-reduction", "rawExp.reduction", "=="); 1077 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 1078 PXOPT_COPY_S16(config->args, where, "-code", "warpSkyfile.fault", "=="); 1230 1079 1231 1080 if (!psListLength(where->list) … … 1246 1095 int numUpdated; // Number updated 1247 1096 { 1097 // This query is no longer necessary because we do not set warpRun's to full statte 1098 // if they have faulted skyfiles. 1099 // We do have runs in the DB that follow the old convention so we leave this in for 1100 // now 1248 1101 psString query = pxDataGet("warptool_revertwarped_update.sql"); 1249 1102 if (!query) { … … 1273 1126 numUpdated = psDBAffectedRows(config->dbh); 1274 1127 1128 #ifdef notdef 1129 // new warpRuns won't get changed (they're already new) so don't require an update 1275 1130 if (numUpdated < 1) { 1276 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");1131 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row"); 1277 1132 if (!psDBRollback(config->dbh)) { 1278 1133 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1280 1135 return false; 1281 1136 } 1137 #endif 1282 1138 } 1283 1139 … … 1462 1318 PS_ASSERT_PTR_NON_NULL(config, NULL); 1463 1319 1464 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false);1320 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false); 1465 1321 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1466 1322 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1467 1323 1468 1324 psMetadata *where = psMetadataAlloc(); 1469 if (warp_id) { 1470 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 1471 } 1325 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 1472 1326 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1473 1327 … … 1624 1478 1625 1479 // note only updates if warpRun.state = run_state 1626 if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) { 1480 // XXX note that we have removed this constraint for now 1481 if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) { 1627 1482 psError(PS_ERR_UNKNOWN, false, "database error"); 1628 1483 // rollback -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptoolConfig.c
r23352 r23594 51 51 // XXX need to allow multiple exp_ids 52 52 psMetadata *definebyqueryArgs = psMetadataAlloc(); 53 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 54 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 55 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 56 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 60 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 61 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 62 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 63 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 64 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 65 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 66 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 67 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 68 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 69 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 70 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 71 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 72 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 73 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 74 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 75 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 76 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 77 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 78 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 79 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 80 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 81 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 82 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 83 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 84 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 85 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 86 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 87 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 88 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 89 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 90 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 91 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 92 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 93 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 94 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search on fakeRun label", NULL); 95 53 pxwarpSetSearchArgs (definebyqueryArgs); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by fakeRun reduction class", NULL); 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search on fakeRun label", NULL); 96 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_mode", 0, "define mode (warp, diff, stack, magic)", NULL); 97 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 123 83 // XXX need to allow multiple exp_ids 124 84 psMetadata *updaterunArgs = psMetadataAlloc(); 125 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 126 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 127 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 128 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 129 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 130 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 131 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 132 psMetadataAddTime(updaterunArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 133 psMetadataAddTime(updaterunArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 134 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 135 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 136 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 137 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 138 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 139 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 140 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 141 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 142 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 143 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 144 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 145 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 146 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 147 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 148 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 149 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 150 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 151 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 152 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 153 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 154 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 155 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 156 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 157 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 158 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 159 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 160 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 161 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 162 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 163 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 164 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 165 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 166 167 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 168 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state", NULL); 169 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "set label", NULL); 170 171 #if 0 172 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 173 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 174 #endif 85 pxwarpSetSearchArgs (updaterunArgs); 86 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 87 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by warpRun reduction class", NULL); 88 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by warpRun state", NULL); 89 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by warpRun label", NULL); 90 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 91 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 92 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 175 93 176 94 // -exp … … 235 153 psMetadataAddF32(addwarpedArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 236 154 psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-accept", 0, "define if this skycell should be accepted", false); 155 psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-magicked", 0, "define if this skycell has been magicked", false); 237 156 psMetadataAddS16(addwarpedArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 238 157 … … 254 173 // XXX need to allow multiple exp_ids 255 174 psMetadata *revertwarpedArgs = psMetadataAlloc(); 175 pxwarpSetSearchArgs(revertwarpedArgs); // XXX does this work here? 256 176 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 257 177 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", NULL); 258 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-tess_id", 0, "searcy by tessellation ID", NULL); 259 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 260 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 261 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 262 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 263 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 264 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 265 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 266 psMetadataAddTime(revertwarpedArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 267 psMetadataAddTime(revertwarpedArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 268 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 269 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 270 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 271 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 272 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 273 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 274 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 275 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 276 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 277 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 278 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 279 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 280 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 281 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 282 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 283 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 284 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 285 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 286 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 287 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 288 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 289 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 290 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 291 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 292 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 293 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 294 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 295 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 296 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 297 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 298 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 299 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 300 178 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tessellation ID", NULL); 179 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-reduction", 0, "search by warpRun reduction class", NULL); 180 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-label", 0, "search by warpRun label", NULL); 301 181 psMetadataAddS16(revertwarpedArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 302 182 psMetadataAddBool(revertwarpedArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); … … 323 203 psMetadata *pendingcleanupskyfileArgs = psMetadataAlloc(); 324 204 psMetadataAddStr(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-label", 0, "list blocks for specified label", NULL); 325 psMetadataAddS64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID ", 0);205 psMetadataAddS64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID (required)", 0); 326 206 psMetadataAddBool(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 327 207 psMetadataAddU64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/cnb_branches/cnb_branch_20090301/ippconfig/gpc1/ppImage.config
r23352 r23594 14 14 15 15 OLDDARK BOOL FALSE 16 17 # use the deburned image instead of the raw, if it exists 18 USE.DEBURNED.IMAGE BOOL TRUE # use burntool-repaired image? 16 19 17 20 ## XXX use these local variations until we are building real detrend images -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/Makefile.am
r20196 r23594 9 9 addstar.config \ 10 10 masks.config \ 11 masks.16bit.config \ 11 12 reductionClasses.mdc \ 12 13 rejections.config \ -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-mef.mdc
r23352 r23594 1 1 ### File rules for PHU=FPA, EXT=CHIP (eg, Megacam) 2 2 ### this file specifies compression types for various output files 3 ### The image types are defined in fitstypes.mdc 4 ### The default type of NONE means no compression 3 5 4 6 ### Redirections (MEF) … … 84 86 PSASTRO.INPUT.CMP INPUT @FILES CHIP CMP 85 87 PSASTRO.INPUT.CMF INPUT @FILES CHIP CMF 88 PSASTRO.INPUT.MASK INPUT @FILES CHIP MASK 89 PSASTRO.REFMASK INPUT @DETDB CHIP MASK 86 90 PSASTRO.WCS INPUT @FILES CHIP CMF 87 91 PSASTRO.MODEL INPUT @DETDB FPA ASTROM 92 93 PSASTRO.EXTRACT.ASTROM INPUT @FILES CHIP CMF 94 PSASTRO.EXTRACT.INPUT INPUT @FILES CHIP IMAGE 88 95 89 96 ## files used by pswarp … … 229 236 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE COMP_WT FPA TRUE NONE 230 237 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 238 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE 231 239 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 232 240 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-simple.mdc
r23352 r23594 1 1 ### File rules for PHU=FPA, EXT=NONE 2 ### The default type of NONE means no compression 3 2 4 3 5 PSASTRO.INPUT STR PSASTRO.INPUT.CMF … … 18 20 PPIMAGE.INPUT.PSF INPUT @FILES READOUT PSF 19 21 PPIMAGE.INPUT.SRC INPUT @FILES READOUT CMF 20 PPIMAGE.MASK INPUT @DETDB CHIP IMAGE22 PPIMAGE.MASK INPUT @DETDB CHIP MASK 21 23 PPIMAGE.BIAS INPUT @DETDB CHIP IMAGE 22 24 PPIMAGE.DARK INPUT @DETDB CHIP DARK … … 47 49 PSASTRO.INPUT.CMP INPUT @FILES CHIP CMP 48 50 PSASTRO.INPUT.CMF INPUT @FILES CHIP CMF 51 PSASTRO.INPUT.MASK INPUT @FILES CHIP MASK 52 PSASTRO.REFMASK INPUT @DETDB CHIP MASK 49 53 PSASTRO.WCS INPUT @FILES CHIP CMF 50 54 PSASTRO.MODEL INPUT @DETDB FPA ASTROM 55 56 PSASTRO.EXTRACT.ASTROM INPUT @FILES CHIP CMF 57 PSASTRO.EXTRACT.INPUT INPUT @FILES CHIP IMAGE 51 58 52 59 ## files used by pswarp … … 181 188 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.weight.fits VARIANCE NONE FPA TRUE NONE 182 189 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 190 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE 183 191 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 184 192 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/filerules-split.mdc
r23352 r23594 1 1 ### File rules for PHU=CHIP, EXT=CELL (eg, GPC1) 2 2 ### this file specifies compression types for various output files 3 ### The default type of NONE means no compression 3 4 4 5 # for basic chip analysis, psphot should produce SPLIT output … … 61 62 PSASTRO.WCS INPUT @FILES CHIP WCS 62 63 PSASTRO.MODEL INPUT @DETDB FPA ASTROM 64 65 PSASTRO.EXTRACT.ASTROM INPUT @FILES CHIP CMF 66 PSASTRO.EXTRACT.INPUT INPUT @FILES CHIP IMAGE 63 67 64 68 ## files used by pswarp … … 119 123 PPIMAGE.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 120 124 PPIMAGE.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE 121 125 122 126 PPIMAGE.STATS OUTPUT {OUTPUT}.{CHIP.NAME}.stats STATS NONE CHIP TRUE NONE 123 127 … … 197 201 PPSTACK.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE COMP_WT FPA TRUE NONE 198 202 PPSTACK.TARGET.PSF OUTPUT {OUTPUT}.target.psf PSF NONE CHIP TRUE NONE 203 PPSTACK.CONV.KERNEL OUTPUT {OUTPUT}.{FILE.INDEX}.kernel SUBKERNEL NONE FPA TRUE NONE 199 204 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 200 205 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/jpeg.mdc
r23352 r23594 182 182 END 183 183 END 184 185 CTEMAP METADATA 186 PPIMAGE.JPEG1 METADATA 187 COLORMAP STR rainbow 188 SCALE.MODE STR VALUE 189 SCALE.MIN F32 0.0 190 SCALE.MAX F32 5.0 191 END 192 193 PPIMAGE.JPEG2 METADATA 194 COLORMAP STR rainbow 195 SCALE.MODE STR VALUE 196 SCALE.MIN F32 0.0 197 SCALE.MAX F32 5.0 198 END 199 END -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/masks.16bit.config
r21185 r23594 8 8 9 9 # Mask values which represent features of the detector 10 DETECTOR U8 0x0001 # Something is wrong with the detector 11 FLAT U8 0x0002 # Pixel doesn't flat-field properly 12 DARK U8 0x0004 # Pixel doesn't dark-subtract properly 13 BLANK U8 0x0008 # Pixel doesn't contain valid data 10 DETECTOR U16 0x0001 # Something is wrong with the detector 11 FLAT U16 0x0002 # Pixel doesn't flat-field properly 12 DARK U16 0x0004 # Pixel doesn't dark-subtract properly 13 BLANK U16 0x0008 # Pixel doesn't contain valid data 14 CTE U16 0x0010 # Pixel has poor Charge Transfer Efficiency 14 15 15 16 # Mask values which represent invalid signal ranges 16 RANGE U8 0x0010 # Pixel is out-of-range of linearity 17 SAT U8 0x0020 # Pixel is saturated 18 BAD U8 0x0040 # Pixel is low (can we rename this 'LOW'?) 17 SAT U16 0x0020 # Pixel is saturated or non-linear 18 LOW U16 0x0040 # Pixel is low 19 SUSPECT U16 0x0080 # Pixel is suspected of being bad 19 20 20 21 # Mask values which represent non-astronomical structures 21 GHOST U8 0x0100 # Pixel contains an optical ghost 22 CR U8 0x0200 # Pixel contains a cosmic ray 23 STREAK U8 0x0400 # Pixel contains a streak 22 CR U16 0x0100 # Pixel contains a cosmic ray 23 SPIKE U16 0x0200 # Pixel contains a diffraction spike 24 GHOST U16 0x0400 # Pixel contains an optical ghost 25 STREAK U16 0x0800 # Pixel contains a streak 26 STARCORE U16 0x1000 # Pixel contains a bright star core 24 27 25 28 # Mask values which identify pixels badly affected by convolutions and interpolations 26 BAD.WARP U8 0x1000 # Pixel is bad after convolution with a bad pixel27 POOR.WARP U8 0x2000 # Pixel is poor after convolution with a bad pixel29 CONV.BAD U16 0x2000 # Pixel is bad after convolution with a bad pixel 30 CONV.POOR U16 0x4000 # Pixel is poor after convolution with a bad pixel 28 31 32 # Spare value for temporary marking 33 # MARK U16 0x8000 # Pixel is temporarily marked -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/masks.config
r20631 r23594 14 14 FLAT U8 0x04 # Pixel doesn't flat-field properly =4 15 15 DARK U8 0x40 # Pixel doesn't dark-subtract properly =64 16 CTE U8 0x40 # Pixel has poor cte 17 16 18 # Filling in the rest with whatever makes some sense 17 19 BLANK U8 0x01 # Pixel doesn't contain valid data … … 24 26 GHOST U8 0x20 # Pixel contains an optical ghost 25 27 STREAK U8 0x20 # Pixel contains a streak 28 29 SPIKE U8 0x20 # Pixel contains a diffraction spike 30 STARCORE U8 0x20 # Pixel contains a streak 26 31 27 32 ###### The following values are what I'm aiming to have in the long term (PAP, 2008-09-09) -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppImage.config
r23352 r23594 19 19 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 20 20 BACKGROUND BOOL FALSE # Subtract model background? 21 CHECK.CTE BOOL FALSE # measure CTE errors? 22 USE.DEBURNED.IMAGE BOOL FALSE # use burntool-repaired image? 21 23 22 24 # output data formats to save … … 77 79 BIN2.XBIN S32 16 78 80 BIN2.YBIN S32 16 81 82 CTE.XBIN S32 20 83 CTE.YBIN S32 20 79 84 80 85 PPIMAGE.JPEG1 METADATA … … 470 475 BASE.FITS BOOL TRUE # Save base detrended image? 471 476 BASE.MASK.FITS BOOL TRUE # Save base detrended image? 472 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image?473 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 474 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 475 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image?477 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image? 478 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 479 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 480 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 476 481 OVERSCAN BOOL TRUE # Overscan subtraction 477 482 BIAS BOOL TRUE # Bias subtraction … … 1417 1422 END 1418 1423 1424 # generate CTE map image 1425 PPIMAGE_CTEMAP METADATA 1426 BASE.FITS BOOL TRUE # Save base image? 1427 BASE.MASK.FITS BOOL TRUE # Save base detrended image? 1428 BASE.VARIANCE.FITS BOOL TRUE # Save base detrended image? 1429 CHIP.FITS BOOL FALSE # Save chip-mosaic-ed image? 1430 CHIP.MASK.FITS BOOL FALSE # Save chip-mosaic-ed image? 1431 CHIP.VARIANCE.FITS BOOL FALSE # Save chip-mosaic-ed image? 1432 OVERSCAN BOOL FALSE # Overscan subtraction 1433 OVERSCAN BOOL TRUE # Overscan subtraction 1434 BIAS BOOL TRUE # Bias subtraction 1435 DARK BOOL TRUE # Dark subtraction 1436 SHUTTER BOOL FALSE # Shutter correction 1437 FLAT BOOL TRUE # Flat-field normalisation 1438 MASK BOOL FALSE # Mask bad pixels 1439 FRINGE BOOL FALSE # Fringe subtraction 1440 PHOTOM BOOL FALSE # Source identification and photometry 1441 ASTROM.CHIP BOOL FALSE # Astrometry per chip? 1442 ASTROM.MOSAIC BOOL FALSE # Astrometry for mosaic? 1443 BIN1.FITS BOOL TRUE # Save 1st binned chip image? 1444 BIN2.FITS BOOL TRUE # Save 2nd binned chip image? 1445 CHECK.CTE BOOL TRUE # measure CTE errors? 1446 END 1447 1419 1448 # For SDSS cameras 1420 1449 PPIMAGE_OA_SOFT METADATA -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppMerge.config
r21370 r23594 14 14 FRINGE.XSMOOTH S32 5 # Number of smoothing regions in x 15 15 FRINGE.YSMOOTH S32 11 # Number of smoothing regions in y 16 CTE.MIN F32 0.2 # regions lower than this in the CTE image are masked 16 17 SHUTTER.SIZE S32 128 # Size for shutter measurement regions 17 18 MASK.SUSPECT F32 5.0 # Threshold for suspect pixels (sigma) … … 94 95 END 95 96 97 # CTEMASK generation combines the images like a flat or bias (mean after outlier rejection), 98 # but it then sets a mask based on the resulting data values (using CTE.MIN) 99 PPMERGE_CTEMASK METADATA 100 REJ F32 3.0 # Rejection threshold (sigma) 101 ITER S32 2 # Number of rejection iterations 102 FRACHIGH F32 0.0 # Fraction of high pixels to reject immediately 103 FRACLOW F32 0.0 # Fraction of low pixels to reject immediately 104 VARIANCES BOOL FALSE # Use image variances? 105 COMBINE STR CLIPPED # Statistic to use for combination: 106 CTE.MIN F32 0.2 # regions lower than this in the CTE image are masked 107 MASK.SET.VALUE STR CTE # set this bit in the output mask 108 END 109 96 110 # Shutter generation --- already included in default, above 97 111 PPMERGE_SHUTTER METADATA -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppSim.config
r20911 r23594 66 66 67 67 GALAXY.MODEL STR PS_MODEL_GAUSS 68 69 BADCTE BOOL FALSE # create a region of 'bad CTE'? 70 BADCTE.REGION STR [0:200,0:200] # region of 'bad CTE' 71 BADCTE.SIGMA F32 2.0 # 'bad CTE' smoothing scale 72 BADCTE.NSIGMA S32 2 # 'bad CTE' smoothing scale 68 73 69 74 BADPIX.SEED U64 123456789 # Seed for RNG in creating deterministic bad pixels … … 185 190 BADPIX.MODE STR NAN # Mode for bad pixels: RANDOM|NAN 186 191 END 192 193 # recipe for a CTE test 194 BADCTE.TEST METADATA 195 BADCTE BOOL TRUE 196 END -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppStack.config
r23352 r23594 1 1 # Recipe configuration for ppStack (image combination) 2 2 3 CONVOLVE BOOL TRUE # Convolve images when stacking? 3 4 ITER S32 1 # Number of rejection iterations 4 5 COMBINE.REJ F32 3.0 # Rejection threshold in combination (sigma) 5 6 COMBINE.SYS F32 0.08 # Relative systematic error in combination 6 7 COMBINE.DISCARD F32 0.2 # Discard fraction for Olympic weighted mean 7 MASK.VAL STR MASK.VALUE, BAD.WARP# Mask value of input bad pixels8 MASK.VAL STR MASK.VALUE,CONV.BAD # Mask value of input bad pixels 8 9 MASK.BAD STR BLANK # Mask value to give bad pixels 9 MASK.POOR STR POOR.WARP# Mask value to give poor pixels10 MASK.POOR STR CONV.POOR # Mask value to give poor pixels 10 11 POOR.FRACTION F32 0.01 # Maximum fraction of bad variance for poor pixels 11 12 THRESHOLD.MASK F32 0.5 # Threshold for mask deconvolution (0..1) -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/ppSub.config
r23352 r23594 15 15 16 16 # EAM : we now ignore these: BAD.WARP is always bad, POOR.WARP is always defined 17 MASK.IN STR MASK.VALUE, BAD.WARP# Mask value for input18 MASK.BAD STR BLANK# Mask value to give bad pixels19 MASK.POOR STR POOR.WARP# Mask value to give poor pixels17 MASK.IN STR MASK.VALUE,CONV.BAD # Mask value for input 18 MASK.BAD STR CONV.BAD # Mask value to give bad pixels 19 MASK.POOR STR CONV.POOR # Mask value to give poor pixels 20 20 21 21 POOR.FRACTION F32 0.10 # Maximum fraction of bad weight for poor pixels -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/psastro.config
r20797 r23594 124 124 REFSTAR_MASK_BLEED_MAG_SLOPE F32 5.0 125 125 126 EXTRACT_MAX_MAG F32 -15.0 127 126 128 # 2MASS default configuration (use 2MASS_J as ref magnitude) 127 129 PSASTRO.CATDIR STR 2MASS -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/reductionClasses.mdc
r23352 r23594 111 111 FLATMASK_JPEG_RESID STR FLAT_RESID 112 112 113 CTEMASK_PROCESS STR PPIMAGE_CTEMAP 114 CTEMASK_RESID STR PPIMAGE_M 115 CTEMASK_VERIFY STR PPIMAGE_M 116 CTEMASK_STACK STR PPMERGE_CTEMASK 117 CTEMASK_JPEG_IMAGE STR CTEMAP 118 CTEMASK_JPEG_RESID STR CTEMAP 119 113 120 FRINGE_PROCESS STR PPIMAGE_OBDSF 114 121 FRINGE_RESID STR PPIMAGE_R -
branches/cnb_branches/cnb_branch_20090301/ippconfig/recipes/rejections.config
r19379 r23594 361 361 362 362 FLATMASK METADATA 363 FILTER STR * 364 EXPECTED F32 0.0 365 IMFILE.MEAN F32 0.0 366 IMFILE.STDEV F32 0.0 367 IMFILE.MEANSTDEV F32 0.0 368 IMFILE.SKEWNESS F32 0.0 369 IMFILE.KURTOSIS F32 0.0 370 IMFILE.SNR F32 0.0 371 IMFILE.BIN.STDEV F32 0.0 372 IMFILE.BIN.SNR F32 0.0 373 IMFILE.FLUX F32 0.0 374 EXP.MEAN F32 0.0 375 EXP.STDEV F32 0.0 376 EXP.MEANSTDEV F32 0.0 377 EXP.SNR F32 0.0 378 EXP.BIN.STDEV F32 0.0 379 EXP.BIN.SNR F32 0.0 380 EXP.FLUX F32 0.0 381 ENSEMBLE.MEAN F32 0.0 382 ENSEMBLE.STDEV F32 0.0 383 ENSEMBLE.MEANSTDEV F32 0.0 384 END 385 386 CTEMASK METADATA 363 387 FILTER STR * 364 388 EXPECTED F32 0.0 -
branches/cnb_branches/cnb_branch_20090301/ippconfig/system.config
r20387 r23594 36 36 37 37 RECIPES METADATA # Site-level recipes 38 MASKS STR recipes/masks. config # Mask values38 MASKS STR recipes/masks.16bit.config # Mask values 39 39 REJECTIONS STR recipes/rejections.config # Rejection for detrend creation 40 40 PPIMAGE STR recipes/ppImage.config # Image reduction -
branches/cnb_branches/cnb_branch_20090301/operations/registration/input
r22426 r23594 66 66 controller host add ipp007 -threads $1 67 67 # ipp008 is flaky 68 controller host add ipp009 -threads $1 68 # ipp009 is registration server 69 69 controller host add ipp010 -threads $1 70 70 controller host add ipp011 -threads $1 … … 104 104 controller host add ipp007 105 105 # ipp008 is flaky 106 controller host add ipp009 106 # ipp009 is registration server 107 107 controller host add ipp010 108 108 controller host add ipp011 -
branches/cnb_branches/cnb_branch_20090301/operations/registration/ptolemy.rc
r22425 r23594 2 2 PANTASKS_SERVER_STDOUT pantasks.stdout.log 3 3 PANTASKS_SERVER_STDERR pantasks.stderr.log 4 PANTASKS_SERVER ipp00 84 PANTASKS_SERVER ipp009 5 5 PASSWORD foobar 6 6 -
branches/cnb_branches/cnb_branch_20090301/ppImage
- Property svn:mergeinfo changed
/branches/eam_branches/eam_branch_20090312/ppImage (added) merged: 23312,23316,23320,23406,23408 /trunk/ppImage merged: 23366,23411,23426,23534-23535
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/Makefile.am
r23352 r23594 21 21 ppMergeFileGroup.c \ 22 22 ppMergeReadChunk.c \ 23 ppMergeLoop _Threaded.c\23 ppMergeLoop.c \ 24 24 ppMergeSetThreads.c \ 25 25 ppMergeMask.c \ -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMerge.c
r23352 r23594 55 55 case PPMERGE_TYPE_FLAT: 56 56 case PPMERGE_TYPE_FRINGE: 57 case PPMERGE_TYPE_CTEMASK: 57 58 if (!ppMergeScaleZero(config)) { 58 59 psErrorStackPrint(stderr, "Error getting scale and zero-points."); -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMerge.h
r23352 r23594 40 40 PPMERGE_TYPE_DARK, ///< (Multi-)Dark frame 41 41 PPMERGE_TYPE_MASK, ///< Mask frame 42 PPMERGE_TYPE_CTEMASK, ///< CTE Mask based on flat variance 42 43 PPMERGE_TYPE_SHUTTER, ///< Shutter frame 43 44 PPMERGE_TYPE_FLAT, ///< Flat-field frame (dome or sky) -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeArguments.c
r21365 r23594 170 170 psMetadataAddS32(arguments, PS_LIST_TAIL, "-fringe-ysmooth", 0, "Number of smoothing regions in y", 0); 171 171 172 /** CTEMASK construction parameters */ 173 psMetadataAddF32(arguments, PS_LIST_TAIL, "-cte-min", 0, "min allowed value for good CTE", NAN); 174 172 175 /** Shutter construction parameters */ 173 176 psMetadataAddS32(arguments, PS_LIST_TAIL, "-shutter-size", 0, "Size for shutter measurement regions", 0); … … 268 271 goto VALID; 269 272 } 273 if (strcasecmp(typeStr, "CTEMASK") == 0) { 274 type = PPMERGE_TYPE_CTEMASK; 275 goto VALID; 276 } 270 277 if (strcasecmp(typeStr, "MASK") == 0 || 271 278 strcasecmp(typeStr, "DARKMASK") == 0 || … … 314 321 VALUE_ARG_RECIPE_INT("-fringe-xsmooth", "FRINGE.XSMOOTH", S32, 0); 315 322 VALUE_ARG_RECIPE_INT("-fringe-ysmooth", "FRINGE.YSMOOTH", S32, 0); 323 324 /** CTEMASK construction parameters */ 325 VALUE_ARG_RECIPE_FLOAT("-cte-min", "CTE.MIN", F32); 316 326 317 327 /** Shutter construction parameters */ -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeCamera.c
r21365 r23594 326 326 fileType = PM_FPA_FILE_MASK; 327 327 break; 328 case PPMERGE_TYPE_CTEMASK: 329 fileType = PM_FPA_FILE_MASK; 330 break; 328 331 case PPMERGE_TYPE_SHUTTER: 329 332 fileType = PM_FPA_FILE_IMAGE; -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeFiles.c
r21365 r23594 209 209 outSuffix = "MASK"; 210 210 break; 211 case PPMERGE_TYPE_CTEMASK: 212 outSuffix = "MASK"; 213 break; 211 214 case PPMERGE_TYPE_SHUTTER: 212 215 outSuffix = "SHUTTER"; -
branches/cnb_branches/cnb_branch_20090301/ppMerge/src/ppMergeScaleZero.c
r23352 r23594 35 35 case PPMERGE_TYPE_BIAS: 36 36 case PPMERGE_TYPE_DARK: 37 case PPMERGE_TYPE_CTEMASK: 37 38 // Nothing to measure 38 39 return true; -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/Makefile.am
r23352 r23594 45 45 ppSimRandomGaussian.c \ 46 46 ppSimBadPixels.c \ 47 ppSimBadCTE.c \ 47 48 ppSimVersion.c 48 49 -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSim.h
r23352 r23594 67 67 } ppSimGalaxy; 68 68 69 ppSimStar *ppSimStarAlloc ();70 ppSimGalaxy *ppSimGalaxyAlloc ();69 ppSimStar *ppSimStarAlloc(void); 70 ppSimGalaxy *ppSimGalaxyAlloc(void); 71 71 72 72 /// Parse command-line arguments … … 135 135 136 136 137 // add a bad CTE region 138 bool ppSimBadCTE(psImage *image, // Signal image, modified and returned 139 const pmConfig *config // configuration 140 ); 141 137 142 /// Add bad pixels to an image 138 143 bool ppSimBadPixels(pmReadout *readout, ///< Readout for which to generate bad pixels … … 184 189 double ppSimRandomGaussian (const psRandom *rnd, double mean, double sigma); 185 190 double ppSimRandomGaussianNorm (const psRandom *rnd); 186 void ppSimRandomGaussianFree( );191 void ppSimRandomGaussianFree(void); 187 192 188 193 bool ppSimPhotomFiles (pmConfig *config, pmFPAfile *fakeFile, pmFPAfile *forceFile); -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimLoadSpots.c
r18047 r23594 57 57 58 58 // load refstars from the catalog 59 psArray *spots = psastroLoadRefstars(config );59 psArray *spots = psastroLoadRefstars(config, "PSASTRO.INPUT"); 60 60 if (!spots || spots->n == 0) { 61 61 psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars."); -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimLoadStars.c
r20040 r23594 41 41 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius); 42 42 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius); 43 psArray *refStars = psastroLoadRefstars(config );43 psArray *refStars = psastroLoadRefstars(config, "PSASTRO.INPUT"); 44 44 if (!refStars) { 45 45 psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars."); -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimLoop.c
r23352 r23594 154 154 done: 155 155 if (!ppSimAddNoise(readout->image, readout->variance, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise"); 156 157 if (!ppSimBadCTE(readout->image, config)) ESCAPE (PS_ERR_UNKNOWN, "problem inducing bad cte"); 158 156 159 if (!ppSimSaturate(readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem setting saturation levels"); 157 160 -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimRandomGaussian.c
r18011 r23594 29 29 30 30 /* integrate a gaussian from -5 sigma to +5 sigma */ 31 void p_ppSimRandomGaussianInit ( ) {32 31 void p_ppSimRandomGaussianInit (void) { 32 33 33 int i; 34 34 long A, B; 35 35 double val, x, dx, dx1, dx2, dx3, df; 36 36 double mean, sigma; 37 37 38 38 /* no need to generate this if it already exists */ 39 39 if (gaussint) return; … … 42 42 for (B = 0; A == time(NULL); B++); 43 43 srand48(B); 44 44 45 45 Ngaussint = 0x1000; 46 46 ppSimRandomGaussianAlloc (Ngaussint + 1); … … 53 53 mean = 0.0; 54 54 sigma = 1.0; 55 55 56 56 for (i = 0, x = -7.0; (i < Ngaussint) && (x < 7.0); x += dx) { 57 df = (3.0*p_ppSimGaussian(x , mean, sigma) + 57 df = (3.0*p_ppSimGaussian(x , mean, sigma) + 58 58 9.0*p_ppSimGaussian(x+dx1, mean, sigma) + 59 9.0*p_ppSimGaussian(x+dx2, mean, sigma) + 59 9.0*p_ppSimGaussian(x+dx2, mean, sigma) + 60 60 3.0*p_ppSimGaussian(x+dx3, mean, sigma)) * (dx1/8.0); 61 61 val += df; … … 67 67 } 68 68 69 // XXX we are using drand48() rather than the random var supplied by rnd 69 // XXX we are using drand48() rather than the random var supplied by rnd 70 70 double ppSimRandomGaussian (const psRandom *rnd, double mean, double sigma) { 71 71 72 72 int i; 73 73 double y; 74 74 75 75 if (gaussint == NULL) { 76 76 p_ppSimRandomGaussianInit (); … … 80 80 i = Ngaussint*y; 81 81 y = gaussint[i]*sigma + mean; 82 82 83 83 return (y); 84 84 85 85 } 86 87 // XXX we are using drand48() rather than the random var supplied by rnd 86 87 // XXX we are using drand48() rather than the random var supplied by rnd 88 88 double ppSimRandomGaussianNorm (const psRandom *rnd) { 89 89 90 90 int i; 91 91 double y; 92 92 93 93 if (gaussint == NULL) { 94 94 p_ppSimRandomGaussianInit (); … … 98 98 i = Ngaussint*y; 99 99 y = gaussint[i]; 100 100 101 101 return (y); 102 102 } -
branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimStars.c
r17557 r23594 6 6 } 7 7 8 ppSimStar *ppSimStarAlloc () {8 ppSimStar *ppSimStarAlloc(void) { 9 9 10 10 ppSimStar *star = (ppSimStar *) psAlloc(sizeof(ppSimStar)); … … 19 19 } 20 20 21 ppSimGalaxy *ppSimGalaxyAlloc () {21 ppSimGalaxy *ppSimGalaxyAlloc(void) { 22 22 23 23 ppSimGalaxy *galaxy = (ppSimGalaxy *) psAlloc(sizeof(ppSimGalaxy)); -
branches/cnb_branches/cnb_branch_20090301/ppStack
- Property svn:mergeinfo changed
/trunk/ppStack merged: 23357,23360,23362,23364,23367-23368,23371-23373,23379,23462,23573,23575-23577
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppStack/src/Makefile.am
r23352 r23594 29 29 ppStackPrepare.c \ 30 30 ppStackConvolve.c \ 31 ppStackCombinePrepare.c \ 31 32 ppStackCombineInitial.c \ 32 33 ppStackReject.c \ -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStack.h
r23352 r23594 7 7 #include <pslib.h> 8 8 #include <psmodules.h> 9 10 #include "ppStackOptions.h" 9 11 10 12 // Mask values for inputs … … 106 108 /// Convolve image to match specified seeing 107 109 bool ppStackMatch(pmReadout *readout, // Readout to be convolved; replaced with output 108 psArray **regions, // Array of regions used in each PSF matching, returned 109 psArray **kernels, // Array of kernels used in each PSF matching, returned 110 float *chi2, // Chi^2 from the stamps 111 float *weighting, // Stack weighting (1/noise^2) 112 psArray *sources, // Array of sources 113 const pmPSF *psf, // Target PSF 114 psRandom *rng, // Random number generator 110 ppStackOptions *options, // Options for stacking 111 int index, // Index of image to match 115 112 const pmConfig *config // Configuration 116 113 ); … … 120 117 /// 121 118 /// Corrects the source PSF photometry to a common system. Return the sum of the exposure times. 122 float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input 123 psVector *inputMask, // Indicates bad input 124 const pmFPAview *view, // View to readout 125 const pmConfig *config // Configuration 119 bool ppStackSourcesTransparency(ppStackOptions *options, // Stacking options 120 const pmFPAview *view, // View to readout 121 const pmConfig *config // Configuration 126 122 ); 127 123 -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackArguments.c
r23352 r23594 20 20 fprintf(stderr, "\nPan-STARRS Image combination\n\n"); 21 21 fprintf(stderr, 22 "Usage: %s INPUTS.mdc OUTPUT_ROOT [-sources STAMPS.cmf | -stamps STAMPS.dat]\n"22 "Usage: %s -input INPUTS.mdc OUTPUT_ROOT [-sources STAMPS.cmf | -stamps STAMPS.dat]\n" 23 23 "where INPUTS.mdc contains various METADATAs, each with:\n" 24 24 "\tIMAGE(STR): Image filename\n" … … 26 26 "\tVARIANCE(STR): Variance map filename\n" 27 27 "\tPSF(STR): PSF filename\n" 28 "\tSOURCES(STR): Sources filename\n" 29 "\tWEIGHTING(F32): Relative weighting to be applied\n", 28 "\tSOURCES(STR): Sources filename\n", 30 29 program); 31 30 fprintf(stderr, "\n"); … … 137 136 psArgumentRemove(argNum, &argc, argv); 138 137 } 139 140 138 141 139 psMetadata *arguments = config->arguments; // Command-line arguments … … 187 185 psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "visualisation", false); 188 186 189 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) {187 if (argc == 1) { 190 188 usage(argv[0], arguments, config); 191 189 } 190 191 if ((argNum = psArgumentGet(argc, argv, "-input"))) { 192 psArgumentRemove(argNum, &argc, argv); 193 if (argNum >= argc) { 194 usage(argv[0], arguments, config); 195 } 196 197 unsigned int numBad = 0; // Number of bad lines 198 psMetadata *inputs = psMetadataConfigRead(NULL, &numBad, argv[argNum], false); // Input file info 199 if (!inputs || numBad > 0) { 200 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to cleanly read MDC file with inputs."); 201 return false; 202 } 203 psMetadataAddMetadata(arguments, PS_LIST_TAIL, "INPUTS", 0, "Metadata with input details", inputs); 204 psFree(inputs); 205 206 psArgumentRemove(argNum, &argc, argv); 207 } 208 209 if (!psArgumentParse(arguments, &argc, argv) || argc != 2) { 210 usage(argv[0], arguments, config); 211 } 212 213 psMetadataAddStr(arguments, PS_LIST_TAIL, "OUTPUT", 0, "Root name of the output image list", argv[1]); 192 214 193 215 const char *stampsName = psMetadataLookupStr(NULL, arguments, "-stamps"); // Name of stamps file 194 216 psMetadataAddStr(arguments, PS_LIST_TAIL, "STAMPS", 0, "Stamps file", stampsName); 195 196 unsigned int numBad = 0; // Number of bad lines197 psMetadata *inputs = psMetadataConfigRead(NULL, &numBad, argv[1], false); // Information about inputs198 if (!inputs || numBad > 0) {199 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to cleanly read MDC file with inputs.");200 return false;201 }202 psMetadataAddMetadata(arguments, PS_LIST_TAIL, "INPUTS", 0, "Metadata with input details", inputs);203 psFree(inputs);204 psMetadataAddStr(arguments, PS_LIST_TAIL, "OUTPUT", 0, "Root name of the output image list", argv[2]);205 217 206 218 valueArgStr(arguments, "-stats", "STATS", arguments); … … 295 307 psTrace("ppStack", 1, "Done parsing arguments\n"); 296 308 297 // Dump configuration, now that's it's settled 298 bool status; 299 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 300 if (dump_file) { 301 pmConfigCamerasCull(config, NULL); 302 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 303 304 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file 305 pmConfigDump(config, input->fpa, dump_file); 306 } 309 pmConfigCamerasCull(config, NULL); 310 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 307 311 308 312 return true; -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackCamera.c
r21366 r23594 11 11 #include "ppStack.h" 12 12 13 14 #if 0 15 // Define an output convolved image file 16 static pmFPAfile *defineOutputConvolved(const char *name, // FPA file name 17 pmFPA *fpa, // FPA to bind 18 const pmConfig *config, // Configuration 19 pmFPAfileType type // Expected type 20 ) 13 // Define a file 14 static pmFPAfile *defineFile(pmConfig *config, // Configuration 15 pmFPAfile *bind, // File to which to bind 16 const char *name, // Name of file rule 17 const char *filename, // Name of file 18 pmFPAfileType type // Type of file 19 ) 21 20 { 22 pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, name); 23 if (!file) { 24 psError(PS_ERR_UNKNOWN, false, "Unable to define output convolved file %s", name); 21 22 psArray *dummy = psArrayAlloc(1); // Dummy array of filenames for this FPA 23 dummy->data[0] = psStringCopy(filename); 24 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "FILENAMES", PS_META_REPLACE, 25 "Filenames for file rule definition", dummy); 26 psFree(dummy); 27 28 bool found = false; // Found the file? 29 pmFPAfile *file = bind ? pmFPAfileBindFromArgs(&found, bind, config, name, "FILENAMES") : 30 pmFPAfileDefineFromArgs(&found, config, name, "FILENAMES"); 31 if (!file || !found) { 32 psError(PS_ERR_UNKNOWN, false, "Unable to define file %s from %s", name, filename); 25 33 return NULL; 26 34 } 27 if (file->type != PM_FPA_FILE_IMAGE) {28 psError(PS_ERR_IO, true, " PPSTACK.OUTCONV is not of type %s", pmFPAfileStringFromType(type));35 if (file->type != type) { 36 psError(PS_ERR_IO, true, "%s is not of type %s", name, pmFPAfileStringFromType(type)); 29 37 return NULL; 30 38 } … … 33 41 } 34 42 35 // Define an input convolved image file, using the output as a basis36 static pmFPAfile *defineInputConvolved(const char *inputName, // Input FPA file name37 pmFPAfile *outFile, // Corresponding output FPA file38 pmConfig *config, // Configuration39 pmFPAfileType type // Expected type40 )41 {42 pmFPAview *view = pmFPAviewAlloc(0); // View into sky cells43 view->chip = view->cell = view->readout = 0;44 45 psString imageName = pmFPANameFromRule(outFile->filerule, outFile->fpa, view);46 psArray *imageNames = psArrayAlloc(1);47 imageNames->data[0] = imageName;48 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "INCONV.FILENAMES", PS_META_REPLACE,49 "Filenames of input convolved image files", imageNames);50 psFree(imageNames);51 bool found = false; // Found the file?52 pmFPAfile *imageFile = pmFPAfileDefineFromArgs(&found, config, "PPSTACK.INCONV",53 "INCONV.FILENAMES");54 psMetadataRemoveKey(config->arguments, "INCONV.FILENAMES");55 if (!imageFile || !found) {56 psError(PS_ERR_UNKNOWN, false, "Unable to define %s file", inputName);57 return NULL;58 }59 if (imageFile->type != type) {60 psError(PS_ERR_IO, true, "PPSTACK.INCONV is not of type %s",61 pmFPAfileStringFromType(type));62 return NULL;63 }64 65 return imageFile;66 }67 #endif68 69 43 70 44 71 45 bool ppStackCamera(pmConfig *config) 72 46 { 73 bool haveVariances = false; // Do we have variance maps? 47 int num = 0; // Number of inputs 48 bool haveVariances = false; // Do we have variance maps? 74 49 bool havePSFs = false; // Do we have PSFs? 75 50 76 psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info 77 psMetadataIterator *iter = psMetadataIteratorAlloc(inputs, PS_LIST_HEAD, NULL); // Iterator 78 psMetadataItem *item; // Item from iteration 79 int i = 0; // Counter 80 while ((item = psMetadataGetAndIncrement(iter))) { 81 if (item->type != PS_DATA_METADATA) { 82 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 83 "Component %s of the input metadata is not of type METADATA", item->name); 84 psFree(iter); 85 return false; 86 } 87 88 psMetadata *input = item->data.md; // The input metadata of interest 89 90 psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image 91 if (!image || strlen(image) == 0) { 92 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name); 93 psFree(iter); 94 return false; 95 } 96 97 bool mdok; 98 psString mask = psMetadataLookupStr(&mdok, input, "MASK"); // Name of mask 99 psString variance = psMetadataLookupStr(&mdok, input, "VARIANCE"); // Name of variance map 100 psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF 101 psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources 102 103 // Add the image file 104 psArray *imageFiles = psArrayAlloc(1); // Array of filenames for this FPA 105 imageFiles->data[0] = psMemIncrRefCounter(image); 106 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "IMAGE.FILENAMES", PS_META_REPLACE, 107 "Filenames of image files", imageFiles); 108 psFree(imageFiles); 109 110 bool found = false; // Found the file? 111 pmFPAfile *imageFile = pmFPAfileDefineFromArgs(&found, config, "PPSTACK.INPUT", "IMAGE.FILENAMES"); 112 if (!imageFile || !found) { 113 psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image); 114 return false; 115 } 116 if (imageFile->type != PM_FPA_FILE_IMAGE) { 117 psError(PS_ERR_IO, true, "PPSTACK.INPUT is not of type IMAGE"); 118 return false; 119 } 120 121 // Optionally add the mask file 122 if (mask && strlen(mask) > 0) { 123 psArray *maskFiles = psArrayAlloc(1); // Array of filenames for this FPA 124 maskFiles->data[0] = psMemIncrRefCounter(mask); 125 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "MASK.FILENAMES", PS_META_REPLACE, 126 "Filenames of mask files", maskFiles); 127 psFree(maskFiles); 128 129 bool status; 130 pmFPAfile *maskFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.MASK", 131 "MASK.FILENAMES"); 51 bool status = false; // Status of file definition 52 53 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim 54 if (!recipe) { 55 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE); 56 return false; 57 } 58 bool convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images before stack? 59 60 psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config, 61 "PPSTACK.INPUT"); // Input images from previous run 62 if (runImages) { 63 // Defining files from the RUN metadata 64 num = runImages->n; 65 66 psArray *runMasks = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 67 "PPSTACK.INPUT.MASK"); // Input masks 68 if (!status) { 69 psError(PS_ERR_UNKNOWN, false, "Unable to define input masks from RUN metadata."); 70 psFree(runImages); 71 return false; 72 } 73 psFree(runMasks); 74 75 psArray *runVars = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 76 "PPSTACK.INPUT.VARIANCE"); // Input variances 77 if (!status) { 78 psError(PS_ERR_UNKNOWN, false, "Unable to define input variances from RUN metadata."); 79 psFree(runImages); 80 return false; 81 } 82 if (runVars) { 83 haveVariances = true; 84 } 85 psFree(runVars); 86 87 psArray *runPSF = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 88 "PPSTACK.INPUT.PSF"); // Input PSFs 89 if (!status) { 90 psError(PS_ERR_UNKNOWN, false, "Unable to define input PSFs from RUN metadata."); 91 psFree(runImages); 92 return false; 93 } 94 if (runPSF) { 95 havePSFs = true; 96 } 97 psFree(runPSF); 98 99 psArray *runSrc = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 100 "PPSTACK.INPUT.SOURCES"); // Input sources 101 if (!status) { 102 psError(PS_ERR_UNKNOWN, false, "Unable to define input sources from RUN metadata."); 103 psFree(runImages); 104 return false; 105 } 106 if (!runSrc) { 107 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata."); 108 psFree(runImages); 109 return false; 110 } 111 psFree(runSrc); 112 113 if (convolve) { 114 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 115 "PPSTACK.CONV.KERNEL"); // Convolution kernels 132 116 if (!status) { 117 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 118 psFree(runImages); 119 return false; 120 } 121 if (!runKernel) { 122 psError(PS_ERR_UNEXPECTED_NULL, true, 123 "Unable to define convolution kernels from RUN metadata."); 124 psFree(runImages); 125 return false; 126 } 127 psFree(runKernel); 128 } 129 130 psFree(runImages); 131 } else { 132 // Defining files from the input metadata 133 psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info 134 if (!inputs) { 135 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find inputs."); 136 return false; 137 } 138 psMetadataIterator *iter = psMetadataIteratorAlloc(inputs, PS_LIST_HEAD, NULL); // Iterator 139 psMetadataItem *item; // Item from iteration 140 int i = 0; // Counter 141 while ((item = psMetadataGetAndIncrement(iter))) { 142 if (item->type != PS_DATA_METADATA) { 143 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 144 "Component %s of the input metadata is not of type METADATA", item->name); 145 psFree(iter); 146 return false; 147 } 148 149 psMetadata *input = item->data.md; // The input metadata of interest 150 151 psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image 152 if (!image || strlen(image) == 0) { 153 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name); 154 psFree(iter); 155 return false; 156 } 157 158 bool mdok; 159 psString mask = psMetadataLookupStr(&mdok, input, "MASK"); // Name of mask 160 psString variance = psMetadataLookupStr(&mdok, input, "VARIANCE"); // Name of variance map 161 psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF 162 psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources 163 164 pmFPAfile *imageFile = defineFile(config, NULL, "PPSTACK.INPUT", 165 image, PM_FPA_FILE_IMAGE); // File for image 166 if (!imageFile) { 167 psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image); 168 return false; 169 } 170 171 if (mask && strlen(mask) > 0 && 172 !defineFile(config, imageFile, "PPSTACK.INPUT.MASK", mask, PM_FPA_FILE_MASK)) { 133 173 psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask); 134 174 return false; 135 175 } 136 if (maskFile->type != PM_FPA_FILE_MASK) { 137 psError(PS_ERR_IO, true, "PPSTACK.INPUT.MASK is not of type MASK"); 138 return false; 139 } 140 } 141 142 // Optionally add the variance file 143 if (variance && strlen(variance) > 0) { 144 haveVariances = true; 145 psArray *varianceFiles = psArrayAlloc(1); // Array of filenames for this FPA 146 varianceFiles->data[0] = psMemIncrRefCounter(variance); 147 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "VARIANCE.FILENAMES", PS_META_REPLACE, 148 "Filenames of variance files", varianceFiles); 149 psFree(varianceFiles); 150 151 bool status; 152 pmFPAfile *varianceFile = pmFPAfileBindFromArgs(&status, imageFile, config, 153 "PPSTACK.INPUT.VARIANCE", "VARIANCE.FILENAMES"); 154 if (!status) { 155 psError(PS_ERR_UNKNOWN, false, "Unable to define file from variance %d (%s)", i, variance); 156 return false; 157 } 158 if (varianceFile->type != PM_FPA_FILE_VARIANCE) { 159 psError(PS_ERR_IO, true, "PPSTACK.INPUT.VARIANCE is not of type VARIANCE"); 160 return false; 161 } 162 } 163 164 // Add the psf file 165 if (!psf || strlen(psf) == 0) { 166 if (havePSFs) { 167 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF %d", i); 168 return false; 169 } 170 } else { 171 if (!havePSFs && i != 0) { 172 psWarning("PSF not provided for all inputs --- ignoring."); 173 } else { 174 psArray *psfFiles = psArrayAlloc(1); // Array of filenames for this FPA 175 psfFiles->data[0] = psMemIncrRefCounter(psf); 176 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "PSF.FILENAMES", PS_META_REPLACE, 177 "Filenames of PSF files", psfFiles); 178 psFree(psfFiles); 179 180 bool status; 181 pmFPAfile *psfFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.PSF", 182 "PSF.FILENAMES"); 183 if (!status) { 184 psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf); 176 177 if (variance && strlen(variance) > 0) { 178 haveVariances = true; 179 if (!defineFile(config, imageFile, "PPSTACK.INPUT.VARIANCE", variance, 180 PM_FPA_FILE_VARIANCE)) { 181 psError(PS_ERR_UNKNOWN, false, 182 "Unable to define file from variance %d (%s)", i, variance); 185 183 return false; 186 184 } 187 if (psfFile->type != PM_FPA_FILE_PSF) { 188 psError(PS_ERR_IO, true, "PPSTACK.INPUT.PSF is not of type PSF"); 185 } 186 187 if (psf && strlen(psf) > 0) { 188 if (i != 0 && !havePSFs) { 189 psWarning("PSF not provided for all inputs --- ignoring."); 190 } else { 191 havePSFs = true; 192 if (!defineFile(config, imageFile, "PPSTACK.INPUT.PSF", psf, PM_FPA_FILE_PSF)) { 193 psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf); 194 return false; 195 } 196 } 197 } else if (havePSFs) { 198 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF %d", i); 199 return false; 200 } 201 202 if (!sources || strlen(sources) == 0) { 203 psError(PS_ERR_UNEXPECTED_NULL, true, "SOURCES not provided for file %d", i); 204 return false; 205 } 206 if (!defineFile(config, imageFile, "PPSTACK.INPUT.SOURCES", sources, PM_FPA_FILE_CMF)) { 207 psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)", 208 i, sources); 209 return false; 210 } 211 212 if (convolve) { 213 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 214 if (!kernel) { 215 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 189 216 return false; 190 217 } 191 havePSFs = true; 192 } 193 } 194 195 // Add the sources file 196 { 197 psArray *sourcesFiles = psArrayAlloc(1); // Array of filenames for this FPA 198 sourcesFiles->data[0] = psMemIncrRefCounter(sources); 199 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "SOURCES.FILENAMES", PS_META_REPLACE, 200 "Filenames of SOURCES files", sourcesFiles); 201 psFree(sourcesFiles); 202 203 bool status; 204 pmFPAfile *sourcesFile = pmFPAfileBindFromArgs(&status, imageFile, config, 205 "PPSTACK.INPUT.SOURCES", "SOURCES.FILENAMES"); 206 if (!status) { 207 psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)", 208 i, sources); 209 return false; 210 } 211 if (sourcesFile->type != PM_FPA_FILE_CMF) { 212 psError(PS_ERR_IO, true, "PPSTACK.INPUT.SOURCES is not of type CMF"); 213 return false; 214 } 215 } 216 217 #if 0 218 // Output convolved files 219 pmFPAfile *outconvImage = defineOutputConvolved("PPSTACK.OUTCONV", imageFile->fpa, config, 220 PM_FPA_FILE_IMAGE); 221 pmFPAfile *outconvMask = defineOutputConvolved("PPSTACK.OUTCONV.MASK", imageFile->fpa, config, 222 PM_FPA_FILE_MASK); 223 pmFPAfile *outconvVariance = defineOutputConvolved("PPSTACK.OUTCONV.VARIANCE", imageFile->fpa, config, 224 PM_FPA_FILE_VARIANCE); 225 if (!outconvImage || !outconvMask || !outconvVariance) { 226 return false; 227 } 228 229 // Input convolved files 230 pmFPAfile *inconvImage = defineInputConvolved("PPSTACK.INCONV", outconvImage, config, 231 PM_FPA_FILE_IMAGE); 232 pmFPAfile *inconvMask = defineInputConvolved("PPSTACK.INCONV.MASK", outconvMask, config, 233 PM_FPA_FILE_MASK); 234 pmFPAfile *inconvVariance = defineInputConvolved("PPSTACK.INCONV.VARIANCE", outconvVariance, config, 235 PM_FPA_FILE_VARIANCE); 236 if (!inconvImage || !inconvMask || !inconvVariance) { 237 return false; 238 } 239 #endif 240 241 i++; 242 } 243 psFree(iter); 244 psMetadataRemoveKey(config->arguments, "IMAGE.FILENAMES"); 245 if (psMetadataLookup(config->arguments, "MASK.FILENAMES")) { 246 psMetadataRemoveKey(config->arguments, "MASK.FILENAMES"); 247 } 248 if (psMetadataLookup(config->arguments, "VARIANCE.FILENAMES")) { 249 psMetadataRemoveKey(config->arguments, "VARIANCE.FILENAMES"); 250 } 251 if (psMetadataLookup(config->arguments, "PSF.FILENAMES")) { 252 psMetadataRemoveKey(config->arguments, "PSF.FILENAMES"); 253 } 254 if (psMetadataLookup(config->arguments, "SOURCES.FILENAMES")) { 255 psMetadataRemoveKey(config->arguments, "SOURCES.FILENAMES"); 256 } 257 258 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", i); 218 kernel->save = true; 219 } 220 221 i++; 222 } 223 psFree(iter); 224 psMetadataRemoveKey(config->arguments, "FILENAMES"); 225 num = i; 226 } 227 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", num); 259 228 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "HAVE.PSF", 0, "Have PSFs available?", havePSFs); 260 229 … … 343 312 } 344 313 jpeg2->save = true; 345 346 347 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim348 if (!recipe) {349 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);350 return false;351 }352 314 353 315 // For photometry, we operate on the chip-mosaicked image -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackCombineInitial.c
r23352 r23594 16 16 psAssert(config, "Require configuration"); 17 17 18 psTimerStart("PPSTACK_FINAL"); 18 if (!options->convolve) { 19 // No need to do initial combination when we haven't convolved 20 return true; 21 } 19 22 20 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 21 psAssert(recipe, "We've thrown an error on this before."); 23 psTimerStart("PPSTACK_INITIAL"); 22 24 23 25 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe … … 25 27 "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans 26 28 27 pmFPAview *view = NULL; // View to readout28 29 int row0, col0; // Offset for readout30 int numCols, numRows; // Size of readout31 ppStackThread *thread = stack->threads->data[0]; // Representative thread32 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {33 psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");34 return false;35 }36 37 pmFPAfileActivate(config->files, false, NULL);38 ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);39 view = ppStackFilesIterateDown(config);40 if (!view) {41 return false;42 }43 44 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell45 options->outRO = pmReadoutAlloc(outCell); // Output readout46 psFree(view);47 48 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad49 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels50 if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {51 psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");52 return false;53 }54 55 psFree(options->cells); options->cells = NULL;56 29 57 30 bool status; // Status of read … … 69 42 } 70 43 71 // call: ppStackReadoutInitial(config, outRO, readouts, subRegions, subKernels)72 44 psThreadJob *job = psThreadJobAlloc("PPSTACK_INITIAL_COMBINE"); // Job to start 73 45 psArrayAdd(job->args, 1, thread); … … 128 100 129 101 if (options->stats) { 130 psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_ FINAL", 0,131 "Time to make final stack", psTimerMark("PPSTACK_ FINAL"));102 psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_INITIAL", 0, 103 "Time to make final stack", psTimerMark("PPSTACK_INITIAL")); 132 104 } 133 105 -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackConvolve.c
r23352 r23594 30 30 int num = options->num; // Number of inputs 31 31 options->cells = psArrayAlloc(num); // Cells for convolved images --- a handle for reading again 32 options-> subKernels = psArrayAlloc(num); // Subtractionkernels --- required in the stacking33 options-> subRegions = psArrayAlloc(num); // Subtractionregions --- required in the stacking32 options->kernels = psArrayAlloc(num); // PSF-matching kernels --- required in the stacking 33 options->regions = psArrayAlloc(num); // PSF-matching regions --- required in the stacking 34 34 int numGood = 0; // Number of good frames 35 35 options->numCols = 0; … … 38 38 psVectorInit(options->matchChi2, NAN); 39 39 options->weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2) 40 psVectorInit(options->weightings, NAN);40 psVectorInit(options->weightings, 0.0); 41 41 options->covariances = psArrayAlloc(num); // Covariance matrices 42 42 … … 78 78 79 79 // Background subtraction, scaling and normalisation is performed automatically by the image matching 80 psArray *regions = NULL, *kernels = NULL; // Regions and kernels used in subtraction81 80 psTimerStart("PPSTACK_MATCH"); 82 83 if (!ppStackMatch(readout, ®ions, &kernels, &options->matchChi2->data.F32[i], 84 &options->weightings->data.F32[i], options->sourceLists->data[i], 85 options->psf, rng, config)) { 81 if (!ppStackMatch(readout, options, i, config)) { 86 82 psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i); 87 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_MATCH;83 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH; 88 84 psErrorClear(); 89 85 continue; … … 92 88 93 89 if (options->stats) { 94 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, readout->analysis,95 PM_SUBTRACTION_ANALYSIS_KERNEL);// Conv kernel96 90 psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_MATCH", PS_META_DUPLICATE_OK, 97 91 "Time to match PSF", psTimerMark("PPSTACK_MATCH")); 98 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.MEAN", PS_META_DUPLICATE_OK,99 "Mean deviation for stamps", kernels->mean);100 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.RMS", PS_META_DUPLICATE_OK,101 "RMS deviation for stamps", kernels->rms);102 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.NUM", PS_META_DUPLICATE_OK,103 "Number of stamps", kernels->numStamps);104 float deconv = psMetadataLookupF32(NULL, readout->analysis,105 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Deconvolution fraction106 psMetadataAddF32(options->stats, PS_LIST_TAIL, "KERNEL.DECONV", PS_META_DUPLICATE_OK,107 "Deconvolution fraction for kernel", deconv);108 92 psMetadataAddF32(options->stats, PS_LIST_TAIL, "PPSTACK.WEIGHTING", PS_META_DUPLICATE_OK, 109 93 "Weighting for image", options->weightings->data.F32[i]); 94 95 if (options->convolve) { 96 // Pull parameters out of convolution kernel 97 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, readout->analysis, 98 PM_SUBTRACTION_ANALYSIS_KERNEL); 99 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.MEAN", PS_META_DUPLICATE_OK, 100 "Mean deviation for stamps", kernels->mean); 101 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.RMS", PS_META_DUPLICATE_OK, 102 "RMS deviation for stamps", kernels->rms); 103 psMetadataAddF32(options->stats, PS_LIST_TAIL, "STAMP.NUM", PS_META_DUPLICATE_OK, 104 "Number of stamps", kernels->numStamps); 105 float deconv = psMetadataLookupF32(NULL, readout->analysis, 106 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); 107 psMetadataAddF32(options->stats, PS_LIST_TAIL, "KERNEL.DECONV", PS_META_DUPLICATE_OK, 108 "Deconvolution fraction for kernel", deconv); 109 } 110 110 } 111 111 psLogMsg("ppStack", PS_LOG_INFO, "Time to match image %d: %f sec", i, psTimerClear("PPSTACK_MATCH")); 112 112 113 options->subRegions->data[i] = regions;114 options->subKernels->data[i] = kernels;115 116 113 // Write the temporary convolved files 117 pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image 118 assert(hdu); 119 ppStackWriteImage(options->imageNames->data[i], hdu->header, readout->image, config); 120 psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask 121 pmConfigMaskWriteHeader(config, maskHeader); 122 ppStackWriteImage(options->maskNames->data[i], maskHeader, readout->mask, config); 123 psFree(maskHeader); 124 psImageCovarianceTransfer(readout->variance, readout->covariance); 125 ppStackWriteImage(options->varianceNames->data[i], hdu->header, readout->variance, config); 114 if (options->convolve) { 115 pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image 116 assert(hdu); 117 ppStackWriteImage(options->imageNames->data[i], hdu->header, readout->image, config); 118 psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask 119 pmConfigMaskWriteHeader(config, maskHeader); 120 ppStackWriteImage(options->maskNames->data[i], maskHeader, readout->mask, config); 121 psFree(maskHeader); 122 psImageCovarianceTransfer(readout->variance, readout->covariance); 123 ppStackWriteImage(options->varianceNames->data[i], hdu->header, readout->variance, config); 126 124 #ifdef TESTING 127 {128 psString name = NULL;129 psStringAppend(&name, "covariance_%d.fits", i);130 ppStackWriteImage(name, hdu->header, readout->covariance->image, config);131 pmStackVisualPlotTestImage(readout->covariance->image, name);132 psFree(name);133 }125 { 126 psString name = NULL; 127 psStringAppend(&name, "covariance_%d.fits", i); 128 ppStackWriteImage(name, hdu->header, readout->covariance->image, config); 129 pmStackVisualPlotTestImage(readout->covariance->image, name); 130 psFree(name); 131 } 134 132 #endif 133 } 135 134 136 135 pmCell *inCell = readout->parent; // Input cell … … 152 151 psFree(rng); 153 152 153 psFree(options->norm); options->norm = NULL; 154 154 psFree(options->sourceLists); options->sourceLists = NULL; 155 155 psFree(options->psf); options->psf = NULL; … … 183 183 184 184 // Reject images out-of-hand on the basis of their match chi^2 185 {185 if (options->convolve) { 186 186 psVector *values = psVectorAllocEmpty(num, PS_TYPE_F32); // Values to sort 187 187 for (int i = 0; i < num; i++) { -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackFiles.c
r23352 r23594 17 17 18 18 /// Files required for the convolution 19 static char *filesConvolve[] = { "PPSTACK.INPUT", "PPSTACK.INPUT.MASK", "PPSTACK.INPUT.VARIANCE", NULL }; 19 static char *filesConvolve[] = { "PPSTACK.INPUT", "PPSTACK.INPUT.MASK", "PPSTACK.INPUT.VARIANCE", 20 "PPSTACK.CONV.KERNEL", NULL }; 20 21 21 22 /// Output files for the combination -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackFinish.c
r23352 r23594 60 60 } 61 61 62 63 // Dump configuration 64 bool mdok; // Status of MD lookup 65 psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config 66 if (dump) { 67 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file 68 pmConfigDump(config, input->fpa, dump); 69 } 70 62 71 return true; 63 72 } -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackLoop.c
r23352 r23594 62 62 return false; 63 63 } 64 psFree(options->cells); options->cells = NULL; 65 66 // Prepare for combination 67 if (!ppStackCombinePrepare(stack, options, config)) { 68 psError(PS_ERR_UNKNOWN, false, "Unable to prepare for combination."); 69 psFree(stack); 70 psFree(options); 71 return false; 72 } 64 73 65 74 // Initial combination … … 103 112 // Clean up 104 113 psTrace("ppStack", 2, "Cleaning up after combination....\n"); 105 if (!ppStackC ombineFinal(stack, options, config)) {114 if (!ppStackCleanup(stack, options, config)) { 106 115 psError(PS_ERR_UNKNOWN, false, "Unable to clean up."); 107 116 psFree(stack); -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackLoop.h
r23352 r23594 34 34 ); 35 35 36 // Prepare for combination 37 bool ppStackCombinePrepare( 38 ppStackThreadData *stack, // Stack 39 ppStackOptions *options, // Options 40 pmConfig *config // Configuration 41 ); 42 36 43 // Initial combination 37 44 bool ppStackCombineInitial( … … 54 61 ); 55 62 63 // Cleanup following combination 64 bool ppStackCleanup( 65 ppStackThreadData *stack, // Stack 66 ppStackOptions *options, // Options 67 pmConfig *config // Configuration 68 ); 69 56 70 // Photometry 57 71 bool ppStackPhotometry( -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackMatch.c
r23352 r23594 163 163 164 164 165 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2, float *weighting, 166 psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config) 165 bool ppStackMatch(pmReadout *readout, ppStackOptions *options, int index, const pmConfig *config) 167 166 { 168 167 assert(readout); 169 assert(regions && !*regions); 170 assert(kernels && !*kernels); 168 assert(options); 171 169 assert(config); 172 *weighting = 0.0;173 170 174 171 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe … … 197 194 } 198 195 199 pmReadout *output = pmReadoutAlloc(NULL); // Output readout, for holding results temporarily 200 201 static int numInput = -1; // Index of input file 202 numInput++; 196 // Match the PSF 197 if (options->convolve) { 198 pmReadout *conv = pmReadoutAlloc(NULL); // Conv readout, for holding results temporarily 203 199 #ifdef TESTING 204 // Read previously produced kernel 205 if (psMetadataLookupBool(NULL, config->arguments, "PPSTACK.DEBUG.STACK")) { 206 const char *outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root 207 assert(outName); 208 // Read convolution kernel 209 psString filename = NULL; // Output filename 210 psStringAppend(&filename, "%s.%d.kernel", outName, numInput); 211 psString resolved = pmConfigConvertFilename(filename, config, false, false); // Resolved filename 212 psFree(filename); 213 psFits *fits = psFitsOpen(resolved, "r"); // FITS file for subtraction kernel 214 psFree(resolved); 215 if (!fits || !pmReadoutReadSubtractionKernels(output, fits)) { 216 psError(PS_ERR_IO, false, "Unable to read previously produced kernel"); 200 // This is a hack to use the temporary convolved images and kernel generated previously. 201 // This makes the 'matching' operation much faster, allowing debugging of the stack process easier. 202 // It implicitly assumes the output root name is the same between invocations. 203 204 // Read previously produced kernel 205 if (psMetadataLookupBool(NULL, config->arguments, "PPSTACK.DEBUG.STACK")) { 206 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.CONV.KERNEL", index); 207 psAssert(file, "Require file"); 208 209 pmFPAview *view = pmFPAviewAlloc(0); // View to readout of interest 210 view->chip = view->cell = view->readout = 0; 211 psString filename = pmFPAfileNameFromRule(filerule->rule, file, view); // Filename of interest 212 213 // Read convolution kernel 214 psString resolved = pmConfigConvertFilename(filename, config, false, false); // Resolved filename 215 psFree(filename); 216 psFits *fits = psFitsOpen(resolved, "r"); // FITS file for subtraction kernel 217 psFree(resolved); 218 if (!fits || !pmReadoutReadSubtractionKernels(conv, fits)) { 219 psError(PS_ERR_IO, false, "Unable to read previously produced kernel"); 220 psFitsClose(fits); 221 return false; 222 } 217 223 psFitsClose(fits); 218 return false; 219 } 220 psFitsClose(fits); 221 222 // Add in variance factor 223 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, output->analysis, 224 PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels 225 float vf = pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); // Variance factor 226 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR"); 227 if (!isfinite(vf)) { 228 vf = 1.0; 229 } 230 if (isfinite(vfItem->data.F32)) { 231 vfItem->data.F32 *= vf; 232 } else { 233 vfItem->data.F32 = vf; 234 } 235 236 // Read image, mask, variance 237 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for image 238 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for mask 239 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for variance map 240 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images 241 psStringAppend(&imageName, "%s.%d.%s", outName, numInput, tempImage); 242 psStringAppend(&maskName, "%s.%d.%s", outName, numInput, tempMask); 243 psStringAppend(&varianceName, "%s.%d.%s", outName, numInput, tempVariance); 244 245 if (!readImage(&readout->image, imageName, config) || !readImage(&readout->mask, maskName, config) || 246 !readImage(&readout->variance, varianceName, config)) { 247 psError(PS_ERR_IO, false, "Unable to read previously produced image."); 224 225 // Add in variance factor 226 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, conv->analysis, 227 PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels 228 float vf = pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); // Variance factor 229 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR"); 230 if (!isfinite(vf)) { 231 vf = 1.0; 232 } 233 if (isfinite(vfItem->data.F32)) { 234 vfItem->data.F32 *= vf; 235 } else { 236 vfItem->data.F32 = vf; 237 } 238 239 if (!readImage(&readout->image, options->imageNames->data[index], config) || 240 !readImage(&readout->mask, options->maskNames->data[index], config) || 241 !readImage(&readout->variance, options->varianceNames->data[index], config)) { 242 psError(PS_ERR_IO, false, "Unable to read previously produced image."); 243 psFree(imageName); 244 psFree(maskName); 245 psFree(varianceName); 246 return false; 247 } 248 248 psFree(imageName); 249 249 psFree(maskName); 250 250 psFree(varianceName); 251 return false; 252 } 253 psFree(imageName); 254 psFree(maskName); 255 psFree(varianceName); 256 257 psRegion *region = psMetadataLookupPtr(NULL, output->analysis, 258 PM_SUBTRACTION_ANALYSIS_REGION); // Convolution region 259 260 pmSubtractionAnalysis(readout->analysis, kernels, region, 261 readout->image->numCols, readout->image->numRows); 262 263 psKernel *kernel = pmSubtractionKernel(kernels, 0.0, 0.0, false); // Convolution kernel 264 psKernel *covar = psImageCovarianceCalculate(kernel, readout->covariance); // New covariance matrix 265 psFree(readout->covariance); 266 readout->covariance = covar; 267 psFree(kernel); 268 269 } else { 270 #endif 271 272 // Normal operations here 273 if (psMetadataLookupBool(&mdok, config->arguments, "HAVE.PSF")) { 274 assert(psf); 275 assert(sources); 251 252 psRegion *region = psMetadataLookupPtr(NULL, conv->analysis, 253 PM_SUBTRACTION_ANALYSIS_REGION); // Convolution region 254 255 pmSubtractionAnalysis(readout->analysis, kernels, region, 256 readout->image->numCols, readout->image->numRows); 257 258 psKernel *kernel = pmSubtractionKernel(kernels, 0.0, 0.0, false); // Convolution kernel 259 psKernel *covar = psImageCovarianceCalculate(kernel, readout->covariance); // Covariance matrix 260 psFree(readout->covariance); 261 readout->covariance = covar; 262 psFree(kernel); 263 } else { 264 #endif 265 266 // Normal operations here 267 psAssert(options->psf, "Require target PSF"); 268 psAssert(options->sourceLists && options->sourceLists->data[index], "Require source list"); 276 269 277 270 int order = psMetadataLookupS32(NULL, ppsub, "SPATIAL.ORDER"); // Spatial polynomial order … … 284 277 float rej = psMetadataLookupF32(NULL, ppsub, "REJ"); // Rejection threshold 285 278 float sysError = psMetadataLookupF32(NULL, ppsub, "SYS"); // Relative systematic error in kernel 286 pmSubtractionKernelsType type = pmSubtractionKernelsTypeFromString(287 psMetadataLookupStr(NULL, ppsub, "KERNEL.TYPE")); // Kernel type279 const char *typeStr = psMetadataLookupStr(NULL, ppsub, "KERNEL.TYPE"); // Kernel type 280 pmSubtractionKernelsType type = pmSubtractionKernelsTypeFromString(typeStr); // Kernel type 288 281 psVector *widths = psMetadataLookupPtr(NULL, ppsub, "ISIS.WIDTHS"); // ISIS Gaussian widths 289 282 psVector *orders = psMetadataLookupPtr(NULL, ppsub, "ISIS.ORDERS"); // ISIS Polynomial orders … … 308 301 } 309 302 310 #if 0311 // Testing the normalisation of the fake image312 {313 pmReadout *test = pmReadoutAlloc(NULL); // Test readout314 psArray *sources = psArrayAlloc(1); // Array of sources315 pmSource *source = pmSourceAlloc(); // Source316 sources->data[0] = source;317 source->peak = pmPeakAlloc(500, 500, 10000, PM_PEAK_LONE);318 source->psfMag = -13.0;319 pmReadoutFakeFromSources(test, 1000, 1000, sources, NULL, NULL, psf, 0.1, 0, false, true);320 float sum = 0.0;321 for (int y = 0; y < test->image->numRows; y++) {322 for (int x = 0; x < test->image->numCols; x++) {323 sum += test->image->data.F32[y][x];324 }325 }326 fprintf(stderr, "Photometry: %f --> %f = -13.0 ???\n", sum, -2.5*log10(sum));327 328 psFits *fits = psFitsOpen("testphot.fits", "w");329 psFitsWriteImage(fits, NULL, test->image, 0, NULL);330 psFitsClose(fits);331 exit(0);332 }333 #endif334 335 303 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF 336 304 337 305 // For the sake of stamps, remove nearby sources 338 psArray *stampSources = stackSourcesFilter(sources, footprint); // Filtered list of sources 306 psArray *stampSources = stackSourcesFilter(options->sourceLists->data[index], 307 footprint); // Filtered list of sources 339 308 340 309 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, 341 stampSources, NULL, NULL, psf, NAN, footprint + size,310 stampSources, NULL, NULL, options->psf, NAN, footprint + size, 342 311 false, true)) { 343 312 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF."); 344 313 psFree(fake); 345 314 psFree(optWidths); 346 psFree( output);315 psFree(conv); 347 316 return false; 348 317 } … … 357 326 pmHDU *hdu = pmHDUFromCell(readout->parent); 358 327 psString name = NULL; 359 psStringAppend(&name, "fake_%03d.fits", numInput);328 psStringAppend(&name, "fake_%03d.fits", index); 360 329 pmStackVisualPlotTestImage(fake->image, name); 361 330 psFits *fits = psFitsOpen(name, "w"); … … 367 336 pmHDU *hdu = pmHDUFromCell(readout->parent); 368 337 psString name = NULL; 369 psStringAppend(&name, "real_%03d.fits", numInput);338 psStringAppend(&name, "real_%03d.fits", index); 370 339 pmStackVisualPlotTestImage(readout->image, name); 371 340 psFits *fits = psFitsOpen(name, "w"); … … 381 350 382 351 // Do the image matching 383 if (!pmSubtractionMatch(output, NULL, readout, fake, footprint, stride, regionSize, spacing, 384 threshold, stampSources, stampsName, type, size, order, widths, orders, 385 inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, 386 optThresh, iter, rej, sysError, maskVal, maskBad, maskPoor, poorFrac, 387 badFrac, PM_SUBTRACTION_MODE_1)) { 388 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 389 psFree(fake); 390 psFree(optWidths); 391 psFree(stampSources); 392 psFree(output); 393 return false; 352 pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readout->analysis, 353 PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel 354 if (kernel) { 355 if (!pmSubtractionMatchPrecalc(conv, NULL, readout, fake, readout->analysis, 356 stride, sysError, maskVal, maskBad, maskPoor, 357 poorFrac, badFrac)) { 358 psError(PS_ERR_UNKNOWN, false, "Unable to convolve images."); 359 psFree(fake); 360 psFree(optWidths); 361 psFree(stampSources); 362 psFree(conv); 363 return false; 364 } 365 } else { 366 if (!pmSubtractionMatch(conv, NULL, readout, fake, footprint, stride, regionSize, spacing, 367 threshold, stampSources, stampsName, type, size, order, widths, 368 orders, inner, ringsOrder, binning, penalty, 369 optimum, optWidths, optOrder, optThresh, iter, rej, sysError, 370 maskVal, maskBad, maskPoor, poorFrac, badFrac, 371 PM_SUBTRACTION_MODE_1)) { 372 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 373 psFree(fake); 374 psFree(optWidths); 375 psFree(stampSources); 376 psFree(conv); 377 return false; 378 } 394 379 } 395 380 … … 398 383 pmHDU *hdu = pmHDUFromCell(readout->parent); 399 384 psString name = NULL; 400 psStringAppend(&name, "conv_%03d.fits", numInput);401 pmStackVisualPlotTestImage( output->image, name);385 psStringAppend(&name, "conv_%03d.fits", index); 386 pmStackVisualPlotTestImage(conv->image, name); 402 387 psFits *fits = psFitsOpen(name, "w"); 403 388 psFree(name); 404 psFitsWriteImage(fits, hdu->header, output->image, 0, NULL);389 psFitsWriteImage(fits, hdu->header, conv->image, 0, NULL); 405 390 psFitsClose(fits); 406 391 } … … 408 393 pmHDU *hdu = pmHDUFromCell(readout->parent); 409 394 psString name = NULL; 410 psStringAppend(&name, "diff_%03d.fits", numInput);395 psStringAppend(&name, "diff_%03d.fits", index); 411 396 pmStackVisualPlotTestImage(fake->image, name); 412 397 psFits *fits = psFitsOpen(name, "w"); 413 398 psFree(name); 414 psBinaryOp(fake->image, output->image, "-", fake->image);399 psBinaryOp(fake->image, conv->image, "-", fake->image); 415 400 psFitsWriteImage(fits, hdu->header, fake->image, 0, NULL); 416 401 psFitsClose(fits); … … 428 413 // Set the variance factor 429 414 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR"); 430 float vf = psMetadataLookupF32(NULL, output->analysis, PM_SUBTRACTION_ANALYSIS_VARFACTOR_1);415 float vf = psMetadataLookupF32(NULL, conv->analysis, PM_SUBTRACTION_ANALYSIS_VARFACTOR_1); 431 416 if (!isfinite(vf)) { 432 417 vf = 1.0; … … 443 428 psFree(readout->variance); 444 429 psFree(readout->covariance); 445 readout->image = psMemIncrRefCounter(output->image); 446 readout->mask = psMemIncrRefCounter(output->mask); 447 readout->variance = psMemIncrRefCounter(output->variance); 448 readout->covariance = psImageCovarianceTruncate(output->covariance, COVAR_FRAC); 449 } else { 450 // Fake the convolution 451 psRegion *region = psRegionAlloc(0, readout->image->numCols - 1, 0, readout->image->numRows - 1); 452 psMetadataAddPtr(output->analysis, PS_LIST_TAIL, PM_SUBTRACTION_ANALYSIS_REGION, 453 PS_DATA_REGION | PS_META_DUPLICATE_OK, "Fake subtraction region", region); 454 psFree(region); 455 pmSubtractionKernels *kernels = pmSubtractionKernelsPOIS(FAKE_SIZE, 0, penalty, 456 PM_SUBTRACTION_MODE_1); 457 // Set solution to delta function 458 kernels->solution1 = psVectorAlloc(kernels->num + 2, PS_TYPE_F64); 459 psVectorInit(kernels->solution1, 0.0); 460 int normIndex = PM_SUBTRACTION_INDEX_NORM(kernels); // Index for normalisation 461 kernels->solution1->data.F64[normIndex] = 1.0; 462 psMetadataAddPtr(output->analysis, PS_LIST_TAIL, PM_SUBTRACTION_ANALYSIS_KERNEL, 463 PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "Fake subtraction kernel", kernels); 464 psFree(kernels); 465 } 466 430 readout->image = psMemIncrRefCounter(conv->image); 431 readout->mask = psMemIncrRefCounter(conv->mask); 432 readout->variance = psMemIncrRefCounter(conv->variance); 433 readout->covariance = psImageCovarianceTruncate(conv->covariance, COVAR_FRAC); 467 434 #ifdef TESTING 468 // Write convolution kernel 435 } 436 #endif 437 438 // Extract the regions and solutions used in the image matching 439 // This stops them from being freed when we iterate back up the FPA 440 psArray *regions = options->regions->data[index] = psArrayAllocEmpty(ARRAY_BUFFER); // Match regions 469 441 { 470 const char *outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root 471 assert(outName); 472 473 psString filename = NULL; // Output filename 474 psStringAppend(&filename, "%s.%d.kernel", outName, numInput); 475 psString resolved = pmConfigConvertFilename(filename, config, true, false); // Resolved filename 476 psFree(filename); 477 psFits *fits = psFitsOpen(resolved, "w"); // FITS file for subtraction kernel 478 psFree(resolved); 479 pmReadoutWriteSubtractionKernels(output, fits); 480 psFitsClose(fits); 481 } 482 } 483 #endif 484 485 readout->analysis = psMetadataCopy(readout->analysis, output->analysis); 486 487 // Extract the regions and solutions used in the image matching 488 // This stops them from being freed when we iterate back up the FPA 489 *regions = psArrayAllocEmpty(ARRAY_BUFFER); // Array of regions 490 { 491 psString regex = NULL; // Regular expression 492 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_REGION); 493 psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator 494 psFree(regex); 495 psMetadataItem *item = NULL;// Item from iteration 496 while ((item = psMetadataGetAndIncrement(iter))) { 497 assert(item->type == PS_DATA_REGION); 498 *regions = psArrayAdd(*regions, ARRAY_BUFFER, item->data.V); 499 } 500 psFree(iter); 501 } 502 *kernels = psArrayAllocEmpty(ARRAY_BUFFER); // Array of kernels 503 { 504 psString regex = NULL; // Regular expression 505 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL); 506 psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator 507 psFree(regex); 508 psMetadataItem *item = NULL;// Item from iteration 509 while ((item = psMetadataGetAndIncrement(iter))) { 510 assert(item->type == PS_DATA_UNKNOWN); 511 // Set the normalisation dimensions, since these will be otherwise unavailable when reading the 512 // images by scans. 513 pmSubtractionKernels *kernel = item->data.V; // Kernel used in subtraction 514 kernel->numCols = readout->image->numCols; 515 kernel->numRows = readout->image->numRows; 516 517 *kernels = psArrayAdd(*kernels, ARRAY_BUFFER, kernel); 518 } 519 psFree(iter); 520 } 521 assert((*regions)->n == (*kernels)->n); 522 523 // Record chi^2 524 { 525 *chi2 = 0.0; 526 int num = 0; // Number of measurements of chi^2 527 psString regex = NULL; // Regular expression 528 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL); 529 psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator 530 psFree(regex); 531 psMetadataItem *item = NULL;// Item from iteration 532 while ((item = psMetadataGetAndIncrement(iter))) { 533 assert(item->type == PS_DATA_UNKNOWN); 534 pmSubtractionKernels *kernels = item->data.V; // Convolution kernels 535 *chi2 += kernels->mean; 536 num++; 537 } 538 psFree(iter); 539 *chi2 /= psImageCovarianceFactor(readout->covariance) * num; 540 } 541 542 // Reject image completely if the maximum deconvolution fraction exceeds the limit 543 float deconv = psMetadataLookupF32(NULL, output->analysis, 544 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Maximum deconvolution fraction 545 if (deconv > deconvLimit) { 546 psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting\n", 547 deconv, deconvLimit); 548 psFree(output); 549 return NULL; 442 psString regex = NULL; // Regular expression 443 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_REGION); 444 psMetadataIterator *iter = psMetadataIteratorAlloc(conv->analysis, PS_LIST_HEAD, regex); 445 psFree(regex); 446 psMetadataItem *item = NULL;// Item from iteration 447 while ((item = psMetadataGetAndIncrement(iter))) { 448 assert(item->type == PS_DATA_REGION); 449 regions = psArrayAdd(regions, ARRAY_BUFFER, item->data.V); 450 } 451 psFree(iter); 452 } 453 psArray *kernels = options->kernels->data[index] = psArrayAllocEmpty(ARRAY_BUFFER); // Match kernels 454 { 455 psString regex = NULL; // Regular expression 456 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL); 457 psMetadataIterator *iter = psMetadataIteratorAlloc(conv->analysis, PS_LIST_HEAD, regex); 458 psFree(regex); 459 psMetadataItem *item = NULL;// Item from iteration 460 while ((item = psMetadataGetAndIncrement(iter))) { 461 assert(item->type == PS_DATA_UNKNOWN); 462 // Set the normalisation dimensions, since these will be otherwise unavailable when reading 463 // the images by scans. 464 pmSubtractionKernels *kernel = item->data.V; // Kernel used in subtraction 465 kernel->numCols = readout->image->numCols; 466 kernel->numRows = readout->image->numRows; 467 468 kernels = psArrayAdd(kernels, ARRAY_BUFFER, kernel); 469 } 470 psFree(iter); 471 } 472 psAssert((regions)->n == (kernels)->n, "Number of match regions and kernels should match"); 473 474 // Record chi^2 475 { 476 double sum = 0.0; // Sum of chi^2 477 int num = 0; // Number of measurements of chi^2 478 psString regex = NULL; // Regular expression 479 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL); 480 psMetadataIterator *iter = psMetadataIteratorAlloc(conv->analysis, PS_LIST_HEAD, regex); 481 psFree(regex); 482 psMetadataItem *item = NULL;// Item from iteration 483 while ((item = psMetadataGetAndIncrement(iter))) { 484 assert(item->type == PS_DATA_UNKNOWN); 485 pmSubtractionKernels *kernels = item->data.V; // Convolution kernels 486 sum += kernels->mean; 487 num++; 488 } 489 psFree(iter); 490 options->matchChi2->data.F32[index] = sum / (psImageCovarianceFactor(readout->covariance) * num); 491 } 492 493 // Reject image completely if the maximum deconvolution fraction exceeds the limit 494 float deconv = psMetadataLookupF32(NULL, conv->analysis, 495 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction 496 if (deconv > deconvLimit) { 497 psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting\n", 498 deconv, deconvLimit); 499 psFree(conv); 500 return NULL; 501 } 502 503 readout->analysis = psMetadataCopy(readout->analysis, conv->analysis); 504 505 psFree(conv); 506 } else { 507 // Match the normalisation 508 float norm = powf(10.0, -0.4 * options->norm->data.F32[index]); // Normalisation 509 psBinaryOp(readout->image, readout->image, "*", psScalarAlloc(norm, PS_TYPE_F32)); 510 psBinaryOp(readout->variance, readout->variance, "*", psScalarAlloc(PS_SQR(norm), PS_TYPE_F32)); 550 511 } 551 512 552 513 // Ensure the background value is zero 553 514 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background 515 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 554 516 if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) { 555 517 psWarning("Can't measure background for image."); … … 565 527 if (!psImageBackground(bg, NULL, readout->variance, readout->mask, maskVal | maskBad, rng)) { 566 528 psError(PS_ERR_UNKNOWN, false, "Can't measure mean variance for image."); 567 psFree(output); 529 psFree(rng); 530 psFree(bg); 568 531 return false; 569 532 } 570 *weighting= 1.0 / (psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN) *571 psImageCovarianceFactor(readout->covariance));533 options->weightings->data.F32[index] = 1.0 / (psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN) * 534 psImageCovarianceFactor(readout->covariance)); 572 535 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHTING", 0, 573 "Weighting by 1/noise^2 for stack", *weighting); 574 536 "Weighting by 1/noise^2 for stack", options->weightings->data.F32[index]); 537 538 psFree(rng); 575 539 psFree(bg); 576 577 #if 0578 #define RADIUS 10 // Radius of photometry579 #define MIN_ERR 0.05 // Minimum photometric error, mag580 #define MAX_MAG -13 // Maximum magnitude for source581 582 // Ensure the normalisation is correct583 // XXX Ideally, would like to do proper PSF-fit photometry, but will settle for aperture photometry584 int numSources = sources->n; // Number of sources585 psVector *ratio = psVectorAlloc(numSources, PS_TYPE_F32); // Flux ratios for sources586 psVector *ratioMask = psVectorAlloc(numSources, PS_TYPE_MASK); // Mask for flux ratios587 psVectorInit(ratioMask, 0xFF);588 psImage *image = readout->image; // Image of interest589 psImage *mask = readout->mask; // Mask of interest590 int numCols = image->numCols, numRows = image->numRows; // Size of image591 for (int i = 0; i < numSources; i++) {592 pmSource *source = sources->data[i]; // Source of interest593 if (!source || source->mode & SOURCE_MASK || !isfinite(source->psfMag) || !isfinite(source->errMag) ||594 source->errMag > MIN_ERR || source->psfMag > MAX_MAG) {595 continue;596 }597 598 float xSrc, ySrc; // Source coordinates599 coordsFromSource(&xSrc, &ySrc, source);600 int xMin = PS_MAX(0, xSrc - RADIUS), xMax = PS_MIN(numCols - 1, xSrc + RADIUS); // Bounds in x601 int yMin = PS_MAX(0, ySrc - RADIUS), yMax = PS_MIN(numRows - 1, ySrc + RADIUS); // Bounds in y602 int numPix = 0; // Number of pixels603 float sum = 0.0; // Sum of pixels604 for (int y = yMin; y <= yMax; y++) {605 for (int x = xMin; x <= xMax; x++) {606 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskBad) {607 continue;608 }609 sum += image->data.F32[y][x];610 numPix++;611 }612 }613 if (sum >= 0 && numPix > 0) {614 float mag = -2.5 * log10(sum * M_PI * PS_SQR(RADIUS) / numPix); // Instrumental magnitude615 ratio->data.F32[i] = mag - source->psfMag;616 ratioMask->data.PS_TYPE_MASK_DATA[i] = 0;617 }618 }619 620 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics621 if (!psVectorStats(stats, ratio, NULL, ratioMask, 0xFF)) {622 psWarning("Unable to measure normalisation --- assuming correct.");623 } else {624 psLogMsg("ppStack", PS_LOG_INFO, "Renormalising image by %f (+/- %f) mag\n",625 stats->robustMedian, stats->robustStdev);626 float norm = powf(10.0, -0.4 * stats->robustMedian); // Normalisation to apply627 psBinaryOp(image, image, "*", psScalarAlloc(norm, PS_TYPE_F32));628 }629 psFree(stats);630 psFree(ratio);631 psFree(ratioMask);632 #endif633 540 634 541 #ifdef TESTING … … 636 543 pmHDU *hdu = pmHDUFromCell(readout->parent); 637 544 psString name = NULL; 638 psStringAppend(&name, "convolved_%03d.fits", numInput);639 pmStackVisualPlotTestImage( output->image, name);545 psStringAppend(&name, "convolved_%03d.fits", index); 546 pmStackVisualPlotTestImage(readout->image, name); 640 547 psFits *fits = psFitsOpen(name, "w"); 641 548 psFree(name); 642 psFitsWriteImage(fits, hdu->header, output->image, 0, NULL);549 psFitsWriteImage(fits, hdu->header, readout->image, 0, NULL); 643 550 psFitsClose(fits); 644 551 } 645 552 #endif 646 647 psFree(output);648 553 649 554 return true; -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackOptions.c
r23352 r23594 18 18 psFree(options->inputMask); 19 19 psFree(options->sourceLists); 20 psFree(options->norm); 20 21 psFree(options->cells); 21 psFree(options-> subKernels);22 psFree(options-> subRegions);22 psFree(options->kernels); 23 psFree(options->regions); 23 24 psFree(options->matchChi2); 24 25 psFree(options->weightings); … … 35 36 psMemSetDeallocator(options, (psFreeFunc)stackOptionsFree); 36 37 38 options->convolve = true; 37 39 options->stats = NULL; 38 40 options->statsFile = NULL; … … 44 46 options->inputMask = NULL; 45 47 options->sourceLists = NULL; 48 options->norm = NULL; 46 49 options->cells = NULL; 47 options-> subKernels = NULL;48 options-> subRegions = NULL;50 options->kernels = NULL; 51 options->regions = NULL; 49 52 options->numCols = 0; 50 53 options->numRows = 0; -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackOptions.h
r23352 r23594 8 8 typedef struct { 9 9 // Setup 10 bool convolve; // Convolve images? 10 11 psMetadata *stats; // Statistics for output 11 12 FILE *statsFile; // File to which to write statistics … … 17 18 psVector *inputMask; // Mask for inputs 18 19 psArray *sourceLists; // Individual lists of sources for matching 20 psVector *norm; // Normalisation for each image 19 21 // Convolve 20 22 psArray *cells; // Cells for convolved images --- a handle for reading again 21 psArray * subKernels; // Subtractionkernels --- required in the stacking22 psArray * subRegions; // Subtractionregions --- required in the stacking23 psArray *kernels; // PSF-matching kernels --- required in the stacking 24 psArray *regions; // PSF-matching regions --- required in the stacking 23 25 int numCols, numRows; // Size of image 24 26 psVector *matchChi2; // chi^2 for stamps from matching -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackPhotometry.c
r23352 r23594 74 74 return false; 75 75 } 76 psFree(photView);77 76 78 77 if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") || … … 93 92 "Time to do photometry", psTimerMark("PPSTACK_PHOT")); 94 93 } 94 psFree(photView); 95 95 96 psLogMsg("ppStack", PS_LOG_INFO, "Time to do photometry: %f sec", psTimerClear("PPSTACK_PHOT")); 96 97 -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackPrepare.c
r23352 r23594 127 127 psVectorInit(options->inputMask, 0); 128 128 129 if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {130 pmFPAfileActivate(config->files, false, NULL);131 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);132 pmFPAview *view = ppStackFilesIterateDown(config);133 if (!view) {134 return false;135 } 136 137 // Generate list of PSFs138 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD,139 "^PPSTACK.INPUT$"); // Iterator140 psMetadataItem *fileItem; // Item from iteration141 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope142 int numCols = 0, numRows = 0; // Size of image143 int index = 0; // Index forfile144 while ((fileItem = psMetadataGetAndIncrement(fileIter))) { 145 assert(fileItem->type == PS_DATA_UNKNOWN);146 pmFPAfile *inputFile = fileItem->data.V; // An input file129 pmFPAfileActivate(config->files, false, NULL); 130 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 131 pmFPAview *view = ppStackFilesIterateDown(config); 132 if (!view) { 133 return false; 134 } 135 136 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, "^PPSTACK.INPUT$"); 137 psMetadataItem *fileItem; // Item from iteration 138 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope 139 int numCols = 0, numRows = 0; // Size of image 140 int index = 0; // Index for file 141 while ((fileItem = psMetadataGetAndIncrement(fileIter))) { 142 assert(fileItem->type == PS_DATA_UNKNOWN); 143 pmFPAfile *inputFile = fileItem->data.V; // An input file 144 145 // Get list of PSFs, to determine target PSF 146 if (options->convolve) { 147 147 pmChip *chip = pmFPAviewThisChip(view, inputFile->fpa); // The chip: holds the PSF 148 148 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF … … 173 173 numRows = naxis2; 174 174 } 175 176 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources 177 psArray *sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources 178 if (!sources) { 179 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout."); 180 return NULL; 181 } 182 options->sourceLists->data[index] = psMemIncrRefCounter(sources); 183 184 // Re-do photometry if we don't trust the source lists 185 if (psMetadataLookupBool(NULL, recipe, "PHOT")) { 186 psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num); 187 pmFPAfileActivate(config->files, false, NULL); 188 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index); 189 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File 190 pmFPAview *photView = ppStackFilesIterateDown(config); 191 if (!photView) { 192 psFree(view); 193 return false; 194 } 195 196 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout of interest 197 198 if (!ppStackInputPhotometer(ro, sources, config)) { 199 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources"); 200 psFree(view); 201 psFree(photView); 202 return false; 203 } 204 175 } 176 177 178 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources 179 psArray *sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources 180 if (!sources) { 181 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout."); 182 return NULL; 183 } 184 options->sourceLists->data[index] = psMemIncrRefCounter(sources); 185 186 // Re-do photometry if we don't trust the source lists 187 if (psMetadataLookupBool(NULL, recipe, "PHOT")) { 188 psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num); 189 pmFPAfileActivate(config->files, false, NULL); 190 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index); 191 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File 192 pmFPAview *photView = ppStackFilesIterateDown(config); 193 if (!photView) { 194 psFree(view); 195 return false; 196 } 197 198 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout of interest 199 200 if (!ppStackInputPhotometer(ro, sources, config)) { 201 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources"); 202 psFree(view); 205 203 psFree(photView); 206 if (!ppStackFilesIterateUp(config)) { 207 psFree(view); 208 return false; 209 } 210 pmFPAfileActivate(config->files, false, NULL); 211 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 212 } 213 214 index++; 215 } 216 psFree(fileIter); 217 218 // Zero point calibration 219 options->sumExposure = ppStackSourcesTransparency(options->sourceLists, options->inputMask, 220 view, config); 221 if (!isfinite(options->sumExposure) || options->sumExposure <= 0) { 222 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences"); 223 psFree(view); 224 return false; 225 } 226 227 // Generate target PSF 204 return false; 205 } 206 207 psFree(photView); 208 if (!ppStackFilesIterateUp(config)) { 209 psFree(view); 210 return false; 211 } 212 pmFPAfileActivate(config->files, false, NULL); 213 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 214 } 215 216 index++; 217 } 218 psFree(fileIter); 219 220 // Generate target PSF 221 if (options->convolve) { 228 222 options->psf = ppStackPSF(config, numCols, numRows, psfs, options->inputMask); 229 223 psFree(psfs); … … 240 234 "Target PSF", options->psf); 241 235 outChip->data_exists = true; 242 236 } 237 238 // Zero point calibration 239 if (!ppStackSourcesTransparency(options, view, config)) { 240 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences"); 243 241 psFree(view); 244 245 if (!ppStackFilesIterateUp(config)) { 246 return false; 247 } 242 return false; 243 } 244 psFree(view); 245 246 if (!ppStackFilesIterateUp(config)) { 247 return false; 248 248 } 249 249 -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackReadout.c
r23352 r23594 150 150 151 151 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, kernelSize, iter, 152 combineRej, combineSys, combineDiscard, true, useVariance, safe )) {152 combineRej, combineSys, combineDiscard, true, useVariance, safe, false)) { 153 153 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 154 154 psFree(stack); … … 185 185 assert(outRO); 186 186 assert(readouts); 187 assert(rejected); 188 assert(readouts->n == rejected->n); 187 assert(!rejected || readouts->n == rejected->n); 189 188 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 190 189 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); … … 197 196 198 197 bool mdok; // Status of MD lookup 198 int iter = psMetadataLookupS32(NULL, recipe, "ITER"); // Rejection iterations 199 float combineRej = psMetadataLookupF32(NULL, recipe, "COMBINE.REJ"); // Combination threshold 200 float combineSys = psMetadataLookupF32(NULL, recipe, "COMBINE.SYS"); // Combination systematic error 201 float combineDiscard = psMetadataLookupF32(NULL, recipe, "COMBINE.DISCARD"); // Olympic discard fraction 199 202 bool useVariance = psMetadataLookupBool(&mdok, recipe, "VARIANCE"); // Use variance for rejection? 203 bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels 200 204 201 205 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in … … 207 211 psArray *stack = psArrayAlloc(num); // Array for stacking 208 212 209 int numGood = num; // Number of good inputs: images that haven't been completely rejected 213 bool entire = true; // Combine entire image? 214 if (rejected) { 215 // We have rejection from a previous combination: combine without flagging pixels to inspect 216 entire = false; 217 safe = false; 218 iter = 0; 219 combineRej = NAN; 220 combineSys = NAN; 221 } 222 210 223 for (int i = 0; i < num; i++) { 211 224 pmReadout *ro = readouts->data[i]; 212 if (!ro || !rejected->data[i] || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 213 // Image completely rejected 214 numGood--; 225 if (mask->data.U8[i] & (PPSTACK_MASK_REJECT | PPSTACK_MASK_BAD)) { 226 // Image completely rejected since previous combination 227 entire = true; 228 continue; 229 } else if (mask->data.U8[i]) { 230 // Image completely rejected before original combination 215 231 continue; 216 232 } … … 234 250 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], 235 251 addVariance ? addVariance->data.F32[i] : NAN); 236 data->reject = psMemIncrRefCounter(rejected->data[i]);252 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 237 253 stack->data[i] = data; 238 254 } 239 255 240 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 0, NAN, NAN, NAN, 241 numGood != num, useVariance, false)) { 256 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 257 iter, combineRej, combineSys, combineDiscard, 258 entire, useVariance, safe, !rejected)) { 242 259 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 243 260 psFree(stack); -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackReject.c
r23352 r23594 14 14 psAssert(options, "Require options"); 15 15 psAssert(config, "Require configuration"); 16 17 if (!options->convolve) { 18 // No need to do complicated rejection when we haven't convolved 19 return true; 20 } 16 21 17 22 int num = options->num; // Number of inputs … … 86 91 87 92 psPixels *reject = pmStackReject(options->inspect->data[i], options->numCols, options->numRows, 88 threshold, poorFrac, stride, options-> subRegions->data[i],89 options-> subKernels->data[i]); // Rejected pixels93 threshold, poorFrac, stride, options->regions->data[i], 94 options->kernels->data[i]); // Rejected pixels 90 95 91 96 #ifdef TESTING … … 141 146 142 147 psFree(options->inspect); options->inspect = NULL; 143 psFree(options-> subKernels); options->subKernels = NULL;144 psFree(options-> subRegions); options->subRegions = NULL;148 psFree(options->kernels); options->kernels = NULL; 149 psFree(options->regions); options->regions = NULL; 145 150 146 151 if (numRejected >= num - 1) { -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackSetup.c
r23352 r23594 11 11 #include "ppStackLoop.h" 12 12 13 #define BUFFER 16 // Buffer for name array 14 15 // Generate an array of input filenames 16 static psArray *stackNameArray(const ppStackOptions *options, // Stack options 17 pmConfig *config, // Configuration 18 const char *name // Name of file 19 ) 20 { 21 psAssert(config, "Require configuration"); 22 psAssert(config, "Require file name"); 23 24 psArray *array = psArrayAllocEmpty(options->num); // Array with filenames 25 pmFPAview *view = pmFPAviewAlloc(0);// View to readout 26 view->chip = view->cell = view->readout = -1; 27 28 for (int i = 0; i < options->num; i++) { 29 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest 30 31 psString filename = pmFPAfileName(file, view, config); // Filename of interest 32 psAssert(filename, "Can't determine filename"); 33 psArrayAdd(array, array->n, filename); 34 psFree(filename); // Drop reference 35 } 36 37 return array; 38 } 39 40 13 41 bool ppStackSetup(ppStackOptions *options, pmConfig *config) 14 42 { … … 18 46 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 19 47 psAssert(recipe, "We've thrown an error on this before."); 48 49 options->convolve = psMetadataLookupBool(NULL, config->arguments, "CONVOLVE"); // Convolve images? 50 if (!psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { 51 psWarning("No PSFs provided --- unable to convolve to common PSF."); 52 options->convolve = false; 53 } 20 54 21 55 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs … … 36 70 } 37 71 38 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 39 if (!tempDir) { 40 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 41 return false; 72 // Generate temporary names for convolved images 73 if (options->convolve) { 74 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 75 if (!tempDir) { 76 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 77 return false; 78 } 79 80 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments, 81 "OUTPUT")); // Name for temporary files 82 const char *tempName = basename(outputName); 83 if (!tempName) { 84 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files."); 85 psFree(outputName); 86 return false; 87 } 88 89 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images 90 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks 91 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps 92 if (!tempImage || !tempMask || !tempVariance) { 93 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 94 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe"); 95 psFree(outputName); 96 return false; 97 } 98 99 options->imageNames = psArrayAlloc(num); 100 options->maskNames = psArrayAlloc(num); 101 options->varianceNames = psArrayAlloc(num); 102 for (int i = 0; i < num; i++) { 103 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images 104 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage); 105 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask); 106 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance); 107 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName); 108 options->imageNames->data[i] = imageName; 109 options->maskNames->data[i] = maskName; 110 options->varianceNames->data[i] = varianceName; 111 } 112 psFree(outputName); 113 } else { 114 options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT"); 115 options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK"); 116 options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE"); 42 117 } 43 44 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments,45 "OUTPUT")); // Name for temporary files46 const char *tempName = basename(outputName);47 if (!tempName) {48 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");49 psFree(outputName);50 return false;51 }52 53 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for temporary images54 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for temporary masks55 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for temp var maps56 if (!tempImage || !tempMask || !tempVariance) {57 psError(PS_ERR_BAD_PARAMETER_VALUE, false,58 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");59 psFree(outputName);60 return false;61 }62 63 options->imageNames = psArrayAlloc(num);64 options->maskNames = psArrayAlloc(num);65 options->varianceNames = psArrayAlloc(num);66 for (int i = 0; i < num; i++) {67 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images68 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage);69 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask);70 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance);71 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName);72 options->imageNames->data[i] = imageName;73 options->maskNames->data[i] = maskName;74 options->varianceNames->data[i] = varianceName;75 }76 psFree(outputName);77 118 78 119 if (!pmConfigMaskSetBits(NULL, NULL, config)) { -
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackSources.c
r23352 r23594 9 9 //#define TESTING // Enable debugging output 10 10 11 #ifdef TESTING 11 12 // Size of fake image; set by hand because it's trouble to get it from other places 12 13 #define FAKE_COLS 4861 13 14 #define FAKE_ROWS 4913 15 #endif 14 16 15 17 #ifdef TESTING … … 53 55 54 56 55 float ppStackSourcesTransparency(const psArray *sourceLists, psVector *inputMask, 56 const pmFPAview *view, const pmConfig *config) 57 bool ppStackSourcesTransparency(ppStackOptions *options, const pmFPAview *view, const pmConfig *config) 57 58 { 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); 62 PS_ASSERT_PTR_NON_NULL(view, NAN); 63 PS_ASSERT_PTR_NON_NULL(config, NAN); 59 PS_ASSERT_PTR_NON_NULL(options, false); 60 PS_ASSERT_PTR_NON_NULL(view, false); 61 PS_ASSERT_PTR_NON_NULL(config, false); 62 63 psArray *sourceLists = options->sourceLists; // Source lists for each input 64 psVector *inputMask = options->inputMask; // Mask for inputs 65 66 PS_ASSERT_ARRAY_NON_NULL(sourceLists, false); 67 PS_ASSERT_VECTOR_NON_NULL(inputMask, false); 68 PS_ASSERT_VECTOR_TYPE(inputMask, PS_TYPE_U8, false); 69 PS_ASSERT_VECTOR_SIZE(inputMask, sourceLists->n, false); 64 70 65 71 #if defined(TESTING) && 0 … … 100 106 if (!airmassZP) { 101 107 psError(PS_ERR_UNKNOWN, false, "Unable to find ZP.AIRMASS in recipe."); 102 return NAN;108 return false; 103 109 } 104 110 … … 139 145 exptime, airmass, expFilter); 140 146 psFree(zp); 141 return NAN;147 return false; 142 148 } 143 149 … … 149 155 "Unable to find airmass term (ZP.AIRMASS) for filter %s", filter); 150 156 psFree(zp); 151 return NAN;157 return false; 152 158 } 153 159 } else if (strcmp(filter, expFilter) != 0) { 154 160 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Filters don't match: %s vs %s", filter, expFilter); 155 161 psFree(zp); 156 return NAN;162 return false; 157 163 } 158 164 … … 160 166 sumExpTime += exptime; 161 167 } 168 169 options->sumExposure = sumExpTime; 162 170 163 171 psArray *matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches … … 165 173 psError(PS_ERR_UNKNOWN, false, "Unable to match sources"); 166 174 psFree(zp); 167 return NAN;175 return false; 168 176 } 169 177 … … 177 185 if (!trans) { 178 186 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies"); 179 return NAN;187 return false; 180 188 } 181 189 … … 186 194 for (int i = 0; i < trans->n; i++) { 187 195 if (!isfinite(trans->data.F32[i])) { 188 inputMask->data.U8[i] = PPSTACK_MASK_CAL;196 inputMask->data.U8[i] |= PPSTACK_MASK_CAL; 189 197 } 190 198 } … … 223 231 // m_0 = m_1 + zp_1 + trans_1 - c1 * airmass_0 - 2.5log(t_0) 224 232 // We don't need to know the magnitude zero point for the filter, since it cancels out 233 options->norm = psVectorAlloc(num, PS_TYPE_F32); 225 234 for (int i = 0; i < num; i++) { 226 235 if (!isfinite(trans->data.F32[i])) { … … 229 238 psArray *sources = sourceLists->data[i]; // Sources of interest 230 239 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i]; 240 options->norm->data.F32[i] = magCorr; 231 241 psLogMsg("ppStack", PS_LOG_INFO, "Applying magnitude correction to image %d: %f\n", i, magCorr); 232 242 … … 248 258 psError(PS_ERR_UNKNOWN, false, "Unable to match sources"); 249 259 psFree(zp); 250 return NAN;260 return false; 251 261 } 252 262 psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej, … … 259 269 #endif 260 270 261 return sumExpTime;271 return true; 262 272 } -
branches/cnb_branches/cnb_branch_20090301/ppStats/src/ppStats.h
r23352 r23594 149 149 150 150 // used by ppStatsFromMetadata: 151 psDataType psDataTypeFromString (char *typename);152 ppStatsEntry *ppStatsEntryAlloc ();151 psDataType psDataTypeFromString(char *typename); 152 ppStatsEntry *ppStatsEntryAlloc(void); 153 153 154 154 psArray *ppStatsFromMetadataEntries (psMetadata *recipe); -
branches/cnb_branches/cnb_branch_20090301/ppSub
- Property svn:mergeinfo changed
/trunk/ppSub merged: 23356,23369,23399,23402-23403,23448-23449,23505,23535
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubArguments.c
r23352 r23594 260 260 } 261 261 262 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[ 3]);262 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]); 263 263 264 264 … … 282 282 const char *refImage = psMetadataLookupStr(NULL, arguments, "-refimage"); // Name of reference image 283 283 if (refImage && strlen(refImage) > 0) { 284 fileList(" INPUT", refImage, "Name of the reference image", config);284 fileList("REF", refImage, "Name of the reference image", config); 285 285 } 286 286 const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubCamera.c
r23352 r23594 33 33 34 34 // look for the file on the RUN metadata 35 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return35 pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return 36 36 if (!status) { 37 37 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); … … 66 66 static pmFPAfile *defineOutputFile(pmConfig *config, // Configuration 67 67 pmFPAfile *template, // File to use as basis for definition 68 bool source, // Is template a source (T), or for binding (F)? 68 69 char *filerule, // Name of file rule 69 70 pmFPAfileType fileType // Type of file … … 71 72 { 72 73 73 pmFPAfile *file = pmFPAfileDefineFromFile(config, template, 1, 1, filerule); 74 pmFPAfile *file = source ? pmFPAfileDefineFromFile(config, template, 1, 1, filerule) : 75 pmFPAfileDefineOutput(config, template->fpa, filerule); 74 76 if (!file) { 75 77 psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule); … … 96 98 97 99 // look for the file on the RUN metadata 98 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return100 pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return 99 101 if (!status) { 100 102 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); … … 108 110 // define new version of file 109 111 if (!file) { 110 pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule);112 file = pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule); 111 113 if (!status) { 112 114 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); … … 160 162 161 163 // Output 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 pmFPAfile *output = defineOutputFile(config, input, true, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE); 165 pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK); 164 166 if (!output || !outMask) { 165 167 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); … … 170 172 pmFPAfile *outVar = NULL; 171 173 if (inVar && refVar) { 172 outVar = defineOutputFile(config, output, "PPSUB.OUTPUT.VARIANCE", PM_FPA_FILE_VARIANCE);174 outVar = defineOutputFile(config, output, false, "PPSUB.OUTPUT.VARIANCE", PM_FPA_FILE_VARIANCE); 173 175 if (!outVar) { 174 176 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); … … 180 182 181 183 // Convolved input image 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 pmFPAfile *inConvImage = defineOutputFile(config, input, true, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE); 185 pmFPAfile *inConvMask = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.MASK", 186 PM_FPA_FILE_MASK); 184 187 if (!inConvImage || !inConvMask) { 185 188 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); … … 187 190 } 188 191 if (inVar) { 189 pmFPAfile *inConvVar = defineOutputFile(config, in put, "PPSUB.INPUT.CONV.VARIANCE",192 pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE", 190 193 PM_FPA_FILE_VARIANCE); 191 194 if (!inConvVar) { … … 196 199 197 200 // Convolved ref image 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); 201 pmFPAfile *refConvImage = defineOutputFile(config, input, true, "PPSUB.REF.CONV", PM_FPA_FILE_IMAGE); 202 pmFPAfile *refConvMask = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.MASK", 203 PM_FPA_FILE_MASK); 200 204 if (!refConvImage || !refConvMask) { 201 205 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); … … 203 207 } 204 208 if (refVar) { 205 pmFPAfile *refConvVar = defineOutputFile(config, input, "PPSUB.REF.CONV.VARIANCE",209 pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE", 206 210 PM_FPA_FILE_VARIANCE); 207 211 if (!refConvVar) { -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubDefineOutput.c
r21524 r23594 26 26 psAssert(view, "Require view"); 27 27 28 // generate an output readout29 28 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT"); // Output cell 30 pmReadout *outRO = pmReadoutAlloc(outCell); // Output readout: subtraction31 29 pmFPA *outFPA = outCell->parent->parent; // Output FPA 32 30 pmHDU *outHDU = outFPA->hdu; // Output HDU 33 31 if (!outHDU->header) { 34 32 outHDU->header = psMetadataAlloc(); 33 } 34 35 // generate an output readout (first check if it's already there by virtue of kernels) 36 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNELS"); // RO with kernel 37 if (!outRO) { 38 outRO = pmReadoutAlloc(outCell); // Output readout: subtraction 35 39 } 36 40 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMatchPSFs.c
r23352 r23594 50 50 51 51 // Load pre-calculated kernel, if available 52 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNEL "); // RO with kernel52 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNELS"); // RO with kernel 53 53 54 54 // Sources in image, used for stamps: these must be loaded from previous analysis stages … … 123 123 float optThresh = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.TOL"); // Tolerance for search 124 124 125 // XXX Do we need/want to define different values for BAD and POOR subtraction vs BAD and POOR warp?126 125 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask in inputs 127 psImageMaskType maskPoor = pmConfigMaskGet(" POOR.WARP", config); // Bits to mask for poor pixels126 psImageMaskType maskPoor = pmConfigMaskGet("CONV.POOR", config); // Bits to mask for poor pixels 128 127 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 129 128 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubSetMasks.c
r21524 r23594 43 43 psAssert(satValue, "SAT must be non-zero"); 44 44 45 psImageMaskType badValue = pmConfigMaskGet("BAD", config); 46 psAssert(badValue, "BAD must be non-zero"); 45 psImageMaskType lowValue = pmConfigMaskGet("LOW", config); 46 if (!lowValue) { 47 // Look up old name for backward compatability 48 lowValue = pmConfigMaskGet("BAD", config); 49 } 50 psAssert(lowValue, "LOW or BAD must be non-zero"); 47 51 48 52 // input images … … 58 62 if (!inRO->mask) { 59 63 if (psMetadataLookupBool(NULL, recipe, "MASK.GENERATE")) { 60 pmReadoutSetMask(inRO, satValue, badValue);64 pmReadoutSetMask(inRO, satValue, lowValue); 61 65 } else { 62 66 inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); … … 66 70 if (!refRO->mask) { 67 71 if (psMetadataLookupBool(NULL, recipe, "MASK.GENERATE")) { 68 pmReadoutSetMask(refRO, satValue, badValue);72 pmReadoutSetMask(refRO, satValue, lowValue); 69 73 } else { 70 74 refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); … … 95 99 float poorFrac = psMetadataLookupF32(&mdok, recipe, "POOR.FRACTION"); // Fraction for "poor" 96 100 97 psImageMaskType maskPoor = pmConfigMaskGet(" POOR.WARP", config); // Bits to mask for poor pixels101 psImageMaskType maskPoor = pmConfigMaskGet("CONV.POOR", config); // Bits to mask for poor pixels 98 102 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels 99 103 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/db/psDB.c
r22708 r23594 1447 1447 1448 1448 mysqlType *mType; // type tmp variable 1449 static bool isNull = true;// used in a MYSQL_BIND to indicate NULL1449 static my_bool isNull = true; // used in a MYSQL_BIND to indicate NULL 1450 1450 1451 1451 MYSQL_BIND *bind = mysqlRow->bind; … … 1472 1472 bind[i].length = 0; 1473 1473 bind[i].buffer = &item->data.U8; 1474 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U8) 1475 ? (my_bool *)&isNull 1476 : NULL; 1474 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U8) ? &isNull : NULL; 1477 1475 break; 1478 1476 } … … 1480 1478 bind[i].length = 0; 1481 1479 bind[i].buffer = &item->data.U16; 1482 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U16) 1483 ? (my_bool *)&isNull 1484 : NULL; 1480 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U16) ? &isNull : NULL; 1485 1481 break; 1486 1482 } … … 1488 1484 bind[i].length = 0; 1489 1485 bind[i].buffer = &item->data.U32; 1490 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U32) 1491 ? (my_bool *)&isNull 1492 : NULL; 1486 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U32) ? &isNull : NULL; 1493 1487 break; 1494 1488 } … … 1496 1490 bind[i].length = 0; 1497 1491 bind[i].buffer = &item->data.U64; 1498 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U64) 1499 ? (my_bool *)&isNull 1500 : NULL; 1492 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.U64) ? &isNull : NULL; 1501 1493 break; 1502 1494 } … … 1504 1496 bind[i].length = 0; 1505 1497 bind[i].buffer = &item->data.S8; 1506 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S8) 1507 ? (my_bool *)&isNull 1508 : NULL; 1498 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S8) ? &isNull : NULL; 1509 1499 break; 1510 1500 } … … 1512 1502 bind[i].length = 0; 1513 1503 bind[i].buffer = &item->data.S16; 1514 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S16) 1515 ? (my_bool *)&isNull 1516 : NULL; 1504 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S16) ? &isNull : NULL; 1517 1505 break; 1518 1506 } … … 1520 1508 bind[i].length = 0; 1521 1509 bind[i].buffer = &item->data.S32; 1522 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S32) 1523 ? (my_bool *)&isNull 1524 : NULL; 1510 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S32) ? &isNull : NULL; 1525 1511 break; 1526 1512 } … … 1528 1514 bind[i].length = 0; 1529 1515 bind[i].buffer = &item->data.S64; 1530 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S64) 1531 ? (my_bool *)&isNull 1532 : NULL; 1516 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.S64) ? &isNull : NULL; 1533 1517 break; 1534 1518 } … … 1536 1520 bind[i].length = 0; 1537 1521 bind[i].buffer = &item->data.F32; 1538 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F32) 1539 ? (my_bool *)&isNull 1540 : NULL; 1522 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F32) ? &isNull : NULL; 1541 1523 break; 1542 1524 } … … 1544 1526 bind[i].length = 0; 1545 1527 bind[i].buffer = &item->data.F64; 1546 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) 1547 ? (my_bool *)&isNull 1548 : NULL; 1528 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) ? &isNull : NULL; 1549 1529 break; 1550 1530 } … … 1558 1538 bind[i].length = 0; 1559 1539 bind[i].buffer = &item->data.B; 1560 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.B) 1561 ? (my_bool *)&isNull 1562 : NULL; 1540 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.B) ? &isNull : NULL; 1563 1541 break; 1564 1542 } … … 1571 1549 bind[i].length = &bind[i].buffer_length; 1572 1550 bind[i].buffer = psStringCopy(item->data.V); 1573 bind[i].is_null = *item->data.str == '\0' 1574 ? (my_bool *)&isNull 1575 : NULL; 1551 bind[i].is_null = *item->data.str == '\0' ? &isNull : NULL; 1576 1552 } else { 1577 1553 // handles the case of NULL as a NULL database value … … 1579 1555 bind[i].length = &bind[i].buffer_length; 1580 1556 bind[i].buffer = NULL; 1581 bind[i].is_null = (my_bool *)&isNull;1557 bind[i].is_null = &isNull; 1582 1558 } 1583 1559 break; … … 1625 1601 bind[i].length = &bind[i].buffer_length; 1626 1602 bind[i].buffer = NULL; 1627 bind[i].is_null = (my_bool *)&isNull;1603 bind[i].is_null = &isNull; 1628 1604 } 1629 1605 break; -
branches/cnb_branches/cnb_branch_20090301/psLib/src/fits/psFitsHeader.c
r23352 r23594 569 569 continue; 570 570 } 571 } else if (keywordInList(name, noWriteCompressedKeys) || 572 (keyStarts && keywordStartsWith(name, noWriteCompressedKeyStarts))) { 573 continue; 571 574 } 572 575 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/imageops/psImageBinning.c
r21107 r23594 31 31 } 32 32 33 psImageBinning *psImageBinningAlloc( ) {33 psImageBinning *psImageBinningAlloc(void) { 34 34 psImageBinning *binning = (psImageBinning*)psAlloc(sizeof(psImageBinning)); 35 35 psMemSetDeallocator(binning, (psFreeFunc)psImageBinningFree); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/imageops/psImageBinning.h
r21107 r23594 42 42 43 43 44 psImageBinning *psImageBinningAlloc( ) PS_ATTR_MALLOC;44 psImageBinning *psImageBinningAlloc(void) PS_ATTR_MALLOC; 45 45 bool psMemCheckBinning(psPtr ptr); 46 46 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/imageops/psImageCovariance.c
r23352 r23594 260 260 { 261 261 PS_ASSERT_IMAGE_NON_NULL(variance, NULL); 262 if (!covar) { 263 // Transferred all we could! 264 return true; 265 } 262 266 PS_ASSERT_KERNEL_NON_NULL(covar, NULL); 263 267 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/jpeg/psImageJpeg.c
r22681 r23594 35 35 } 36 36 37 psImageJpegColormap *psImageJpegColormapAlloc ()37 psImageJpegColormap *psImageJpegColormapAlloc(void) 38 38 { 39 39 psImageJpegColormap *map = psAlloc(sizeof(psImageJpegColormap)); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/jpeg/psImageJpeg.h
r14452 r23594 1 1 /* @file psImageJpeg.h 2 2 * @brief functions to generate JPEG images from psImage 3 * 3 * 4 4 * @author EAM 5 5 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ … … 28 28 29 29 // allocate a colormap (does not define the map values) 30 psImageJpegColormap *psImageJpegColormapAlloc( ) PS_ATTR_MALLOC;30 psImageJpegColormap *psImageJpegColormapAlloc(void) PS_ATTR_MALLOC; 31 31 32 32 // set the colormap values using the supplied name -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psMinimizeLMM.c
r21183 r23594 95 95 // check for non-finite entries in result 96 96 for (int i = 0; i < Beta->n; i++) { 97 if (!isfinite(Beta->data.F32[i])) {98 // psError(PS_ERR_BAD_PARAMETER_VALUE, 3, "Fit value diverges: vector[%d] is %.2f\n", i, Beta->data.F32[i]);99 return false;100 }97 if (!isfinite(Beta->data.F32[i])) { 98 // psError(PS_ERR_BAD_PARAMETER_VALUE, 3, "Fit value diverges: vector[%d] is %.2f\n", i, Beta->data.F32[i]); 99 return false; 100 } 101 101 } 102 102 … … 104 104 // (we must do this before truncating Beta below) 105 105 if (dLinear) { 106 *dLinear = psMinLM_dLinear(Beta, beta, lambda);107 } 108 109 // full-length Beta for checkLimits functions 106 *dLinear = psMinLM_dLinear(Beta, beta, lambda); 107 } 108 109 // full-length Beta for checkLimits functions 110 110 psVector *tmpBeta = psVectorAlloc(params->n, PS_TYPE_F32); 111 111 psVectorInit (tmpBeta, 0.0); … … 113 113 // set tmpBeta values which are not masked 114 114 for (int j = 0, n = 0; j < params->n; j++) { 115 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;116 tmpBeta->data.F32[j] = Beta->data.F32[n];117 n++;115 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 116 tmpBeta->data.F32[j] = Beta->data.F32[n]; 117 n++; 118 118 } 119 119 … … 127 127 if (checkLimits) { 128 128 checkLimits (PS_MINIMIZE_BETA_LIMIT, j, Params->data.F32, tmpBeta->data.F32); 129 }129 } 130 130 131 131 Params->data.F32[j] = params->data.F32[j] - tmpBeta->data.F32[j]; … … 135 135 checkLimits (PS_MINIMIZE_PARAM_MIN, j, Params->data.F32, tmpBeta->data.F32); 136 136 checkLimits (PS_MINIMIZE_PARAM_MAX, j, Params->data.F32, tmpBeta->data.F32); 137 }137 } 138 138 } 139 139 140 140 // apply tmpBeta after limits have been checked 141 141 for (int j = 0, n = 0; j < params->n; j++) { 142 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;143 Beta->data.F32[n] = tmpBeta->data.F32[j];144 n++;142 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; 143 Beta->data.F32[n] = tmpBeta->data.F32[j]; 144 n++; 145 145 } 146 146 … … 169 169 // if none are available, return false 170 170 if (!psMinLM_AllocAB (&Alpha, &Beta, params, paramMask)) { 171 return false;171 return false; 172 172 } 173 173 … … 241 241 // beta only counts unmasked parameters 242 242 for (int i = 0; i < beta->n; i++) { 243 dh = lambda*B[i] + b[i];244 sh = 0.5*B[i]*dh;245 Sh += sh;243 dh = lambda*B[i] + b[i]; 244 sh = 0.5*B[i]*dh; 245 Sh += sh; 246 246 dLinear += lambda*PS_SQR(B[i]) + B[i]*b[i]; 247 247 } … … 295 295 assert (!isnan(chisq)); 296 296 297 // we track alpha,beta and params,deriv separately297 // we track alpha,beta and params,deriv separately 298 298 for (int j = 0, J = 0; j < params->n; j++) { 299 299 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue; … … 304 304 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 305 305 alpha->data.F32[J][K] += weight * deriv->data.F32[k]; 306 K++;306 K++; 307 307 } 308 308 beta->data.F32[J] += weight * delta; 309 J++;309 J++; 310 310 } 311 311 } … … 328 328 between that function at the specified coords and the specified value at those 329 329 coords. 330 330 331 331 This requires F32 input data; all internal calls use F32. 332 332 XXX Make an F64 version? … … 386 386 // Alpha & Beta only contain elements to represent the unmasked parameters 387 387 if (!psMinLM_AllocAB (&Alpha, &Beta, params, paramMask)) { 388 psAbort ("programming error: no unmasked parameters to be fit\n");389 } 390 388 psAbort ("programming error: no unmasked parameters to be fit\n"); 389 } 390 391 391 psImage *alpha = psImageAlloc(Alpha->numCols, Alpha->numRows, PS_TYPE_F32); 392 392 psVector *beta = psVectorAlloc(Beta->n, PS_TYPE_F32); … … 490 490 psTrace ("psLib.math", 5, "failure to calculate covariance matrix\n"); 491 491 } 492 // set covar values which are not masked493 psImageInit (covar, 0.0);494 for (int j = 0, J = 0; j < params->n; j++) {495 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {496 covar->data.F32[j][j] = 1.0;497 continue;498 }499 for (int k = 0, K = 0; k < params->n; k++) {500 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;501 covar->data.F32[j][k] = Alpha->data.F32[J][K];502 K++;503 }504 J++;505 }492 // set covar values which are not masked 493 psImageInit (covar, 0.0); 494 for (int j = 0, J = 0; j < params->n; j++) { 495 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) { 496 covar->data.F32[j][j] = 1.0; 497 continue; 498 } 499 for (int k = 0, K = 0; k < params->n; k++) { 500 if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue; 501 covar->data.F32[j][k] = Alpha->data.F32[J][K]; 502 K++; 503 } 504 J++; 505 } 506 506 } 507 507 … … 533 533 // count unmasked parameters 534 534 if (paramMask) { 535 nParams = 0;536 for (int i = 0; i < paramMask->n; i++) {537 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;538 nParams ++;539 }540 } 541 542 if (nParams == 0) { 543 return false;535 nParams = 0; 536 for (int i = 0; i < paramMask->n; i++) { 537 if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 538 nParams ++; 539 } 540 } 541 542 if (nParams == 0) { 543 return false; 544 544 } 545 545 … … 585 585 } 586 586 587 psMinConstraint* psMinConstraintAlloc( )587 psMinConstraint* psMinConstraintAlloc(void) 588 588 { 589 589 psMinConstraint *tmp = psAlloc(sizeof(psMinConstraint)); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psMinimizeLMM.h
r15046 r23594 94 94 psMinConstraint; 95 95 96 psMinConstraint *psMinConstraintAlloc( ) PS_ATTR_MALLOC;96 psMinConstraint *psMinConstraintAlloc(void) PS_ATTR_MALLOC; 97 97 98 98 /** Allocates a psMinimization structure. … … 174 174 psF32 lambda); 175 175 176 // allocate alpha and beta for unmasked parameters only 176 // allocate alpha and beta for unmasked parameters only 177 177 bool psMinLM_AllocAB (psImage **Alpha, psVector **Beta, const psVector *params, const psVector *paramMask); 178 178 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psSparse.c
r19501 r23594 245 245 psSparseBorder *psSparseBorderAlloc(psSparse *sparse, int Nborder) 246 246 { 247 psAssert(sparse->Nrows > 0, "Require positive size: nrows = %d", sparse->Nrows); 248 psAssert(Nborder > 0, "Require positive size: nborder = %d", Nborder); 249 247 250 psSparseBorder *border = (psSparseBorder *)psAlloc(sizeof(psSparseBorder)); 248 251 psMemSetDeallocator(border, (psFreeFunc) psSparseBorderFree); … … 451 454 square = psImageCopy (square, border->Tjj, PS_TYPE_F64); 452 455 if (!psMatrixGJSolve (square, Go)) { 453 psError(PS_ERR_UNKNOWN, false, "Unable to solve for lower square.");454 psFree (dG);455 psFree (Go);456 psFree (dF);457 psFree (Fo);458 psFree (square);459 return false;460 }456 psError(PS_ERR_UNKNOWN, false, "Unable to solve for lower square."); 457 psFree (dG); 458 psFree (Go); 459 psFree (dF); 460 psFree (Fo); 461 psFree (square); 462 return false; 463 } 461 464 yVec = psVectorCopy (yVec, Go, PS_TYPE_F32); 462 465 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psSpline.c
r12434 r23594 103 103 tabulated function at n points, this routine calculates the second 104 104 derivatives of the interpolating cubic splines at those n points. 105 105 106 106 The first and second derivatives at the endpoints were previously undefined in 107 107 the SDR. From bugzilla #???, they are required to be 0.0, implementing natural 108 108 splines. 109 109 110 110 Endpoints are defined by 111 111 PS_LEFT_SPLINE_DERIV 112 112 PS_RIGHT_SPLINE_DERIV 113 113 114 114 This routine assumes that vectors x and y are of the appropriate types/sizes 115 115 (F32). 116 116 117 117 XXX: use recycled vectors for internal data. 118 118 XXX: do an F64 version? … … 177 177 } 178 178 179 psSpline1D *psSpline1DAlloc( )179 psSpline1D *psSpline1DAlloc(void) 180 180 { 181 181 psSpline1D *tmpSpline = (psSpline1D *) psAlloc(sizeof(psSpline1D)); … … 192 192 psVectorFitSpline1D(): given a set of x/y vectors, this routine generates the 193 193 linear or cublic splines which satisfy those data points. 194 194 195 195 The formula for calculating the spline polynomials is derived from Numerical 196 196 Recipes in C. The basic idea is that the polynomial is … … 206 206 into a polynomial in terms of x, and then saving the coefficients of the 207 207 powers of x in the spline polynomials. This gets pretty complicated. 208 208 209 209 XXX: What types must be supported? 210 210 *****************************************************************************/ … … 354 354 (vectorBinDisectF32()). Then it evaluates the spline at that x location 355 355 by a call to the 1D polynomial functions. 356 356 357 357 XXX: The spline eval functions require input and output to be F32. however 358 358 the spline fit functions require F32 and F64. 359 359 360 360 XXX: This only works if spline->knots if psF32. Must we add support for psU32 and 361 361 psF64? -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psSpline.h
r14452 r23594 46 46 * @return psSpline1D* new 1-D spline struct 47 47 */ 48 psSpline1D *psSpline1DAlloc( ) PS_ATTR_MALLOC;48 psSpline1D *psSpline1DAlloc(void) PS_ATTR_MALLOC; 49 49 50 50 /** Evaluates 1-D spline polynomials at a specific coordinate. -
branches/cnb_branches/cnb_branch_20090301/psLib/src/math/psStats.c
r23352 r23594 265 265 for (long i = 0; i < num; i++) { 266 266 // Check if the data is with the specified range 267 if (maskData && (maskData[i] & maskVal)) { 267 if (!isfinite(vector[i])) 268 continue; 269 if (useRange && (vector[i] < stats->min)) 268 270 continue; 269 } 270 271 if (useRange) { 272 if (vector[i] < stats->min || vector[i] > stats->max) { 273 continue; 274 } 275 } else if (!isfinite(vector[i])) { 276 stats->max = stats->min = NAN; 277 psError(PS_ERR_IEEE, true, "Element %ld of vector is Inf/NaN", i); 278 return 0; 279 } 271 if (useRange && (vector[i] > stats->max)) 272 continue; 273 if (maskData && (maskData[i] & maskVal)) 274 continue; 280 275 281 276 numValid++; -
branches/cnb_branches/cnb_branch_20090301/psLib/src/mathtypes/psImage.c
r21347 r23594 55 55 56 56 // drop my entry on my parent's array of children 57 // lock parent before freeing child : psArrayRemoveDataNoFree is NOT thread safe58 psMutexLock (parent);57 // lock parent before freeing child : psArrayRemoveDataNoFree is NOT thread safe 58 psMutexLock (parent); 59 59 psArrayRemoveDataNoFree (parent->children, image); 60 psMutexUnlock (parent);60 psMutexUnlock (parent); 61 61 62 62 // drop my reference to my parent … … 87 87 int rowSize = numCols * elementSize; // row size in bytes. 88 88 89 if (numRows < 1) { 90 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 91 _("Specified number of rows (%d) or columns (%d) is invalid."), 92 numRows, numCols); 93 return NULL; 94 } 95 if (numCols < 1) { 96 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 97 _("Specified number of rows (%d) or columns (%d) is invalid."), 98 numRows, numCols); 99 return NULL; 89 if (numRows < 1 || numCols < 1) { 90 psAbort(_("Specified number of rows (%d) or columns (%d) is invalid."), numRows, numCols); 100 91 } 101 92 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psError.c
r19034 r23594 146 146 147 147 psErrorCode p_psErrorV(const char* filename, 148 unsigned int lineno,149 const char* func,150 psErrorCode code,151 bool new,152 const char* format,153 va_list ap)148 unsigned int lineno, 149 const char* func, 150 psErrorCode code, 151 bool new, 152 const char* format, 153 va_list ap) 154 154 { 155 155 char errMsg[MAX_STRING_LENGTH]; … … 245 245 } 246 246 247 long psErrorGetStackSize( )247 long psErrorGetStackSize(void) 248 248 { 249 249 psArray *errorStack = psErrorStackGet(); -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psError.h
r19034 r23594 87 87 * @return int The number of items on the error stack 88 88 */ 89 long psErrorGetStackSize( );89 long psErrorGetStackSize(void); 90 90 91 91 -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psLogMsg.c
r23352 r23594 76 76 } 77 77 78 int psLogGetLevel( )78 int psLogGetLevel(void) 79 79 { 80 80 return globalLogLevel; -
branches/cnb_branches/cnb_branch_20090301/psLib/src/sys/psLogMsg.h
r14452 r23594 63 63 * @return int: The current file descriptor. 64 64 */ 65 int psLogGetDestination( );65 int psLogGetDestination(void); 66 66 67 67 … … 83 83 * @return int: The current logging level. 84 84 */ 85 int psLogGetLevel( );85 int psLogGetLevel(void); 86 86 87 87 /** This procedure sets the log format for future log messages. The argument -
branches/cnb_branches/cnb_branch_20090301/psModules
- Property svn:mergeinfo changed
/trunk/psModules merged: 23354,23358,23370,23374,23378,23404-23405,23428,23432,23447,23450-23452,23476,23487,23498,23535,23574,23576-23577,23587
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryDistortion.c
r21183 r23594 40 40 } 41 41 42 pmAstromGradient *pmAstromGradientAlloc ( )42 pmAstromGradient *pmAstromGradientAlloc (void) 43 43 { 44 44 … … 126 126 grad = pmAstromGradientAlloc (); 127 127 128 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 7);128 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 7); 129 129 130 130 // fit the collection of positions and offsets with a local 1st order gradient … … 138 138 grad->dTPdM.x = local->coeff[0][1]; 139 139 140 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 0);140 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 0); 141 141 142 142 // fit the collection of positions and offsets with a local 1st order gradient -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryDistortion.h
r12486 r23594 27 27 pmAstromGradient; 28 28 29 pmAstromGradient *pmAstromGradientAlloc ( );29 pmAstromGradient *pmAstromGradientAlloc (void); 30 30 31 31 /* The following function determines the position residual, in the tangent -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.c
r23351 r23594 47 47 /* Initialization Routines */ 48 48 49 bool pmAstromVisualClose( )49 bool pmAstromVisualClose(void) 50 50 { 51 51 if(kapa != -1) -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.h
r23351 r23594 26 26 /** Close plotting windows at the end of a run 27 27 * @return true for success */ 28 bool pmAstromVisualClose( );28 bool pmAstromVisualClose(void); 29 29 30 30 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPARead.c
r22699 r23594 554 554 } 555 555 psFree(header); 556 bad = pmConfigMaskGet("BAD", config); 556 bad = pmConfigMaskGet("LOW", config); 557 if (!bad) { 558 // XXX look up old name for compatability 559 bad = pmConfigMaskGet("BAD", config); 560 } 557 561 break; 558 562 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAWrite.c
r23351 r23594 172 172 173 173 if (writeBlank || writeImage) { 174 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 175 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 176 if (!pmConceptsWriteCell(cell, source, true, config)) { 174 if (!pmConceptsWriteCell(cell, true, config)) { 177 175 psError(PS_ERR_IO, false, "Unable to write concepts for cell."); 178 176 return false; … … 225 223 226 224 if (writeBlank || writeImage) { 227 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 228 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 229 if (!pmConceptsWriteChip(chip, source, true, true, config)) { 225 if (!pmConceptsWriteChip(chip, true, true, config)) { 230 226 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n"); 231 227 return false; … … 294 290 295 291 if (writeBlank || writeImage) { 296 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 297 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 298 if (!pmConceptsWriteFPA(fpa, source, true, config)) { 292 if (!pmConceptsWriteFPA(fpa, true, config)) { 299 293 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 300 294 return false; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.c
r23351 r23594 20 20 #include "pmConceptsCopy.h" 21 21 22 static int fileNum = 0; // Number of file 23 22 24 static void pmFPAfileFree(pmFPAfile *file) 23 25 { … … 56 58 } 57 59 58 pmFPAfile *pmFPAfileAlloc( )60 pmFPAfile *pmFPAfileAlloc(void) 59 61 { 60 62 pmFPAfile *file = psAlloc(sizeof(pmFPAfile)); … … 100 102 101 103 file->save = false; 104 105 file->index = fileNum++; 102 106 103 107 file->imageId = 0; … … 350 354 psStringSubstitute(&newRule, name, "{OUTPUT}"); 351 355 } 356 } 357 358 if (strstr(newRule, "{FILE.INDEX}")) { 359 // Number of the file in list 360 psString num = NULL; // Number to use 361 psStringAppend(&num, "%d", file->index); 362 psStringSubstitute(&newRule, num, "{FILE.INDEX}"); 363 psFree(num); 352 364 } 353 365 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.h
r23351 r23594 109 109 psString formatName; // name of the camera format 110 110 111 int index; // Index of file 112 111 113 psS64 imageId, sourceId; // Image and source identifiers 112 114 } pmFPAfile; 113 115 114 116 // allocate an empty pmFPAfile structure 115 pmFPAfile *pmFPAfileAlloc ();117 pmFPAfile *pmFPAfileAlloc(void); 116 118 117 119 // select the readout from the named pmFPAfile; if the named file does not exist, -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.c
r23351 r23594 382 382 383 383 // place the resulting file in the config system 384 psMetadataAddPtr(config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "Output file", file); 384 psMetadataAddPtr(config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, 385 "Output file", file); 385 386 psFree(file); // we free this copy of file, but 'files' still has a copy 386 387 return file; // the returned value is a view into the version on 'files' … … 719 720 } 720 721 721 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pm Config *config, const char *filename)722 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pmFPAfile *bind, pmConfig *config, const char *filename) 722 723 { 723 724 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 732 733 } 733 734 734 pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, filenames); // File of interest735 pmFPAfile *file = fpaFileDefineFromArray(config, bind, filename, filenames); // File of interest 735 736 psFree(filenames); 736 737 … … 742 743 } 743 744 745 psArray *pmFPAfileDefineMultipleFromRun(bool *success, psArray *bind, pmConfig *config, const char *filename) 746 { 747 PS_ASSERT_PTR_NON_NULL(config, NULL); 748 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 749 750 if (success) { 751 *success = false; 752 } 753 754 psArray *files = pmConfigRunFileGet(config, filename); // Filenames used, to return 755 if (!files || files->n == 0) { 756 if (success) { 757 *success = true; 758 } 759 return NULL; 760 } 761 if (bind && files->n != bind->n) { 762 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 763 "Length of filenames (%ld) and bind files (%ld) does not match.", 764 files->n, bind->n); 765 psFree(files); 766 return NULL; 767 } 768 769 psArray *dummy = psArrayAlloc(1); // Dummy array of single filename 770 for (int i = 0; i < files->n; i++) { 771 psFree(dummy->data[0]); 772 dummy->data[0] = files->data[i]; 773 pmFPAfile *bindFile = bind ? bind->data[i] : NULL; // File to which to bind 774 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy)); 775 if (!files->data[i]) { 776 psError(PS_ERR_UNKNOWN, false, "Unable to define file %s %d", filename, i); 777 psFree(dummy); 778 psFree(files); 779 return NULL; 780 } 781 } 782 psFree(dummy); 783 784 if (success) { 785 *success = true; 786 } 787 788 return files; 789 } 744 790 745 791 // define the named pmFPAfile from the camera->config -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.h
r23351 r23594 67 67 pmFPAfile *pmFPAfileDefineFromRun( 68 68 bool *found, ///< Found files? 69 pmFPAfile *bind, ///< File to which to bind, or NULL 69 70 pmConfig *config, ///< Configuration 70 71 const char *filename ///< Name of file 71 72 ); 72 73 74 /// Define multiple files based on the filenames in the RUN metadata in the configuration 75 /// 76 /// An array of the files defined is returned 77 psArray *pmFPAfileDefineMultipleFromRun( 78 bool *found, ///< Found files? 79 psArray *bind, ///< Files to which to bind, or NULL 80 pmConfig *config, ///< Configuration 81 const char *filename ///< Name of file 82 ); 73 83 74 84 // look for the given argname on the argument list. find the give filename from the file rules -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileFitsIO.c
r22699 r23594 183 183 } 184 184 185 pmConceptSource sources = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |186 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; // Concept sources to write187 185 if (cell) { 188 if (!pmConceptsWriteCell(cell, sources,true, config)) {186 if (!pmConceptsWriteCell(cell, true, config)) { 189 187 psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n"); 190 188 return false; 191 189 } 192 190 } else if (chip) { 193 if (!pmConceptsWriteChip(chip, sources,true, true, config)) {191 if (!pmConceptsWriteChip(chip, true, true, config)) { 194 192 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n"); 195 193 return false; 196 194 } 197 } else if (!pmConceptsWriteFPA(fpa, sources,true, config)) {195 } else if (!pmConceptsWriteFPA(fpa, true, config)) { 198 196 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 199 197 return false; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileIO.c
r23351 r23594 166 166 } 167 167 168 if (!pmConfigRunFileAdd (config, file)) {168 if (!pmConfigRunFileAddRead(config, file)) { 169 169 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 170 170 return false; … … 421 421 } 422 422 423 if (!pmConfigRunFileAdd (config, file)) {423 if (!pmConfigRunFileAddWrite(config, file)) { 424 424 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 425 425 return false; … … 635 635 } 636 636 637 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config) 638 { 639 PS_ASSERT_PTR_NON_NULL(file, NULL); 640 PS_ASSERT_PTR_NON_NULL(view, NULL); 641 PS_ASSERT_PTR_NON_NULL(config, NULL); 642 643 psString filename = pmFPAfileNameFromRule(file->filerule, file, view); // Filename, based on rule 644 if (!filename) { 645 psError(PS_ERR_IO, true, "Cannot determine file name from rule"); 646 return false; 647 } 648 649 // indirect filenames: these come from a list on the command line or elsewhere 650 if (!strcasecmp(filename, "@FILES")) { 651 psString filesrc = pmFPAfileNameFromRule(file->filesrc, file, view); // Source of file name 652 if (!filesrc) { 653 psError(PS_ERR_IO, false, "error converting filesrc to name %s", file->filesrc); 654 return false; 655 } 656 psFree(filename); 657 filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, file->names, filesrc)); 658 if (!filename) { 659 psError(PS_ERR_IO, false, "filename lookup error (@FILES) for %s : %s", file->filesrc, filesrc); 660 psFree(filesrc); 661 return false; 662 } 663 psFree(filesrc); 664 } 665 666 // get name from detrend database 667 // file->detrend->detID contains the desired -det_id detID -iteration iter string 668 if (!strcasecmp(filename, "@DETDB")) { 669 if (!file->detrend) { 670 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 671 return false; 672 } 673 psMetadata *menu = psMetadataLookupMetadata(NULL, file->camera, "CLASSID"); // Menu of class IDs 674 if (!menu) { 675 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 676 return false; 677 } 678 const char *rule = psMetadataLookupStr(NULL, menu, file->detrend->level); // Rule for class_id 679 if (!rule || strlen(rule) == 0) { 680 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", 681 file->detrend->level); 682 return false; 683 } 684 psString classId = pmFPAfileNameFromRule(rule, file, view); // The class identifier, for pmDetrendFile 685 if (!classId) { 686 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 687 return false; 688 } 689 690 psTrace("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 691 psFree(filename); 692 filename = pmDetrendFile(file->detrend->detID, classId, config); 693 if (!filename) { 694 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s", 695 file->detrend->detID, classId); 696 psFree(classId); 697 return false; 698 } 699 700 psTrace("psModules.camera", 6, "got detrend file %s", filename); 701 psFree(classId); 702 } 703 704 return filename; 705 } 706 637 707 // open file (if not already opened). 638 708 // this function is only called only within pmFPAfileRead or pmFPAfileWrite. … … 672 742 673 743 // determine the file name, free a name allocated earlier 674 psFree (file->filename); 675 file->filename = pmFPAfileNameFromRule (file->filerule, file, view); 676 if (file->filename == NULL) { 677 psError(PS_ERR_IO, true, "Filename is NULL"); 678 return false; 679 } 680 681 // indirect filenames: these come from a list on the command line or elsewhere 682 if (!strcasecmp (file->filename, "@FILES")) { 683 char *filesrc = pmFPAfileNameFromRule (file->filesrc, file, view); 684 if (filesrc == NULL) { 685 psError(PS_ERR_IO, false, "error converting filesrc to name %s\n", file->filesrc); 686 return false; 687 } 688 689 psFree (file->filename); 690 file->filename = psMetadataLookupStr (&status, file->names, filesrc); 691 692 if (file->filename == NULL) { 693 psError(PS_ERR_IO, true, "filename lookup error (@FILES) for %s : %s\n", file->filesrc, filesrc); 694 psFree (filesrc); 695 return false; 696 } 697 // psMetadataLookupStr just returns a view, file->filename must be protected 698 psMemIncrRefCounter (file->filename); 699 psFree (filesrc); 700 } 701 702 // get name from detrend database 703 // file->detrend->detID contains the desired -det_id detID -iteration iter string 704 if (!strcasecmp (file->filename, "@DETDB")) { 705 if (!file->detrend) { 706 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 707 return false; 708 } 709 710 psString classId = NULL; // The class identifier, to pass to pmDetrendFile 711 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "CLASSID"); // Menu of class IDs 712 if (!status || !menu) { 713 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 714 return false; 715 } 716 const char *rule = psMetadataLookupStr(&status, menu, file->detrend->level); // Rule for class_id 717 if (!status || !rule || strlen(rule) == 0) { 718 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", file->detrend->level); 719 return false; 720 } 721 classId = pmFPAfileNameFromRule(rule, file, view); 722 if (!classId) { 723 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 724 return false; 725 } 726 psTrace ("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 727 psFree (file->filename); 728 729 file->filename = pmDetrendFile(file->detrend->detID, classId, config); 730 if (file->filename == NULL) { 731 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s\n", file->detrend->detID, classId); 732 psFree (classId); 733 return false; 734 } 735 736 psTrace ("psModules.camera", 6, "got detrend file %s\n", file->filename); 737 psFree (classId); 744 psFree(file->filename); 745 file->filename = pmFPAfileName(file, view, config); 746 if (!file->filename) { 747 psError(PS_ERR_IO, true, "Unable to determine filename"); 748 return false; 738 749 } 739 750 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileIO.h
r18364 r23594 15 15 /// @addtogroup Camera Camera Layout 16 16 /// @{ 17 18 // Determine appropriate file name 19 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config); 17 20 18 21 // open the real file corresponding to the given pmFPAfile appropriate to the current view -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsStandard.c
r23351 r23594 606 606 } 607 607 608 // Get the current value of a concept 609 static psMetadataItem *conceptGet(const pmFPA *fpa, // FPA of interest 610 const pmChip *chip, // Chip of interest, or NULL 611 const pmCell *cell, // Cell of interest, or NULL 612 const char *name // Concept name 613 ) 614 { 615 psMetadataItem *item = NULL; // Item with time system 616 if (cell) { 617 item = psMetadataLookup(cell->concepts, name); 618 } 619 if (!item && chip) { 620 item = psMetadataLookup(chip->concepts, name); 621 } 622 if (!item && fpa) { 623 item = psMetadataLookup(fpa->concepts, name); 624 } 625 if (!item) { 626 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts", name); 627 return NULL; 628 } 629 return item; 630 } 631 632 // Determine the corresponding TIMESYS for one of the TIME concepts 633 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 634 const pmFPA *fpa, // FPA of interest 635 const pmChip *chip, // Chip of interest, or NULL 636 const pmCell *cell // Cell of interest, or NULL 637 ) 638 { 639 assert(name); 640 641 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 642 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 643 psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system 644 psFree(timesysName); 645 646 if (!item || item->type != PS_TYPE_S32) { 647 psWarning("Unable to find %s --- assuming UTC", timesysName); 648 return PS_TIME_UTC; 649 } 650 return item->data.S32; 651 } 652 653 // Set the corresponding TIMESYS for one of the TIME concepts 654 static bool conceptSetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 655 const pmFPA *fpa, // FPA of interest 656 const pmChip *chip, // Chip of interest, or NULL 657 const pmCell *cell, // Cell of interest, or NULL 658 psTimeType timeSys // The time system value 659 ) 660 { 661 assert(name); 662 663 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 664 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 665 psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system 666 psFree(timesysName); 667 668 if (!item) { 669 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts when setting %s\n", 670 timesysName, name); 671 return false; 672 } 673 674 if (item->data.S32 != -1 && item->data.S32 != timeSys) { 675 psWarning("Time system is set to %x; but should be %x", item->data.S32, timeSys); 676 } 677 678 item->data.S32 = timeSys; 679 680 return true; 681 } 608 682 609 683 psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept, … … 622 696 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 623 697 // XXX is this too low verbosity? 624 ps LogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name);698 psWarning("Can't interpret %s --- assuming UTC.", pattern->name); 625 699 } else if (strcasecmp(sys, "TAI") == 0) { 626 700 timeSys = PS_TIME_TAI; … … 633 707 } else { 634 708 // XXX is this too low verbosity? 635 psLogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name); 709 psWarning("Can't interpret %s --- assuming UTC.", pattern->name); 710 } 711 712 psMetadataItem *old = conceptGet(fpa, chip, cell, pattern->name); // Old value 713 if (old && old->data.S32 != -1 && old->data.S32 != timeSys) { 714 psWarning("%s is already set (%x) and not consistent with new value (%x)", 715 pattern->name, old->data.S32, timeSys); 636 716 } 637 717 … … 639 719 } 640 720 641 // Determine the corresponding TIMESYS for one of the TIME concepts 642 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 643 const pmFPA *fpa, // FPA of interest 644 const pmChip *chip, // Chip of interest, or NULL 645 const pmCell *cell // Cell of interest, or NULL 646 ) 647 { 648 assert(name); 649 650 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 651 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 652 bool mdok = false; // Result of MD lookup 653 psTimeType timeSys = 0xFFFFFFFF; // The time system 654 if (cell) { 655 timeSys = psMetadataLookupS32(&mdok, cell->concepts, timesysName); 656 } 657 if (!mdok && chip) { 658 timeSys = psMetadataLookupS32(&mdok, chip->concepts, timesysName); 659 } 660 if (!mdok && fpa) { 661 timeSys = psMetadataLookupS32(&mdok, fpa->concepts, timesysName); 662 } 663 if (!mdok || (timeSys == 0xFFFFFFFF)) { 664 psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n", 665 timesysName, name); 666 timeSys = PS_TIME_UTC; 667 } 668 psFree(timesysName); 669 670 return timeSys; 671 } 721 672 722 673 723 psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept, … … 896 946 } 897 947 898 time->type = timeSys; 948 if (jdTime || mjdTime) { 949 conceptSetTimesysForTime(pattern->name, fpa, chip, cell, PS_TIME_TAI); 950 } else { 951 time->type = timeSys; 952 } 899 953 900 954 psMetadataItem *item = psMetadataItemAllocPtr(pattern->name, PS_DATA_TIME, pattern->comment, time); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsWrite.c
r22699 r23594 62 62 while ((cItem = psListGetAndIncrement(cIter))) { 63 63 if (cItem->type != PS_DATA_STRING) { 64 psWarning("psMetadataItem from list is of type %x instead of " 65 "%x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 64 psWarning("psMetadataItem from list is of type %x instead of %x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 66 65 psFree(cIter); 67 66 psFree(sIter); … … 183 182 } 184 183 default: 185 psWarning("Type of %s is not suitable for a FITS header --- not added.\n",184 psWarning("Type of %s is not suitable for a FITS header --- not added.\n", 186 185 item->name); 187 186 return false; … … 226 225 } 227 226 227 // Return the camera format appropriate for a focal plane hierarchy 228 static psMetadata *conceptsCameraFormat(const pmFPA *fpa, const pmChip *chip, const pmCell *cell) 229 { 230 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 231 if (!hdu) { 232 return NULL; 233 } 234 return hdu->format; 235 } 236 237 // Return the DATABASE metadata from the format 238 static psMetadata *conceptsDatabase(const psMetadata *format) 239 { 240 bool mdok; // Status of MD lookup 241 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 242 } 243 244 // Return the TRANSLATION metadata from the format 245 static psMetadata *conceptsTranslation(const psMetadata *format) 246 { 247 bool mdok; // Status of MD lookup 248 return psMetadataLookupMetadata(&mdok, format, "TRANSLATION"); 249 } 250 251 // Return the DEFAULTS metadata from the format 252 static psMetadata *conceptsDefaults(const psMetadata *format) 253 { 254 bool mdok; // Status of MD lookup 255 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 256 } 257 228 258 229 259 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 231 261 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 232 262 233 bool p_pmConceptsWriteToCells(const psMetadata *specs, const pmCell *cell, const psMetadata *concepts) 234 { 235 PS_ASSERT_PTR_NON_NULL(specs, false); 236 PS_ASSERT_PTR_NON_NULL(concepts, false); 263 bool p_pmConceptWriteToCells(const pmCell *cell, const pmConceptSpec *spec, 264 const psMetadataItem *conceptItem, const psMetadata *format) 265 { 237 266 if (!cell) { 238 267 return false; … … 242 271 } 243 272 244 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 273 if (!format) { 274 format = conceptsCameraFormat(NULL, NULL, cell); 275 if (!format) { 276 return false; 277 } 278 } 279 280 psMetadataItem *cameraItem = psMetadataLookup(cell->config, conceptItem->name); // Version in the config 281 if (!cameraItem) { 282 return false; 283 } 284 285 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 286 psStringAppend(&nameSource, "%s.SOURCE", conceptItem->name); 287 bool mdok = true; // Status of MD lookup 288 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 289 if (mdok && strlen(source) > 0) { 290 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 291 if (strcasecmp(source, "HEADER") == 0) { 292 if (cameraItem->type != PS_DATA_STRING) { 293 psWarning("Concept %s is specified by header, but is not of type STR --- ignored.", 294 conceptItem->name); 295 psFree(nameSource); 296 return false; 297 } 298 299 // Formatted version 300 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 301 format, NULL, NULL, cell); 302 if (!formatted) { 303 psFree(nameSource); 304 return true; 305 } 306 307 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", 308 conceptItem->name, cameraItem->data.str); 309 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // Header data unit 310 if (!hdu) { 311 psError(PS_ERR_UNEXPECTED_NULL, false, 312 "Unable to find HDU to write concept %s", conceptItem->name); 313 return false; 314 } 315 writeHeader(hdu, cameraItem->data.V, formatted); 316 psFree(formatted); 317 } else if (strcasecmp(source, "VALUE") == 0) { 318 // Formatted version 319 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 320 format, NULL, NULL, cell); 321 if (!formatted) { 322 psFree(nameSource); 323 return true; 324 } 325 326 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", conceptItem->name); 327 if (!compareConcepts(formatted, cameraItem)) { 328 psWarning("Concept %s is specified by value in the camera format, but the values don't match", 329 conceptItem->name); 330 } 331 psFree(formatted); 332 } else { 333 psWarning("Concept source %s isn't HEADER or VALUE --- can't write", nameSource); 334 } 335 } else { 336 // Assume it's specified by value 337 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 338 format, NULL, NULL, cell); 339 if (!formatted) { 340 psFree(nameSource); 341 return true; 342 } 343 344 if (!compareConcepts(formatted, cameraItem)) { 345 psWarning("Concept %s is specified by value in the camera format, but the values don't match.", 346 conceptItem->name); 347 } 348 psFree(formatted); 349 } 350 psFree(nameSource); 351 352 return true; 353 } 354 355 bool p_pmConceptWriteToDefaults(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 356 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 357 const psMetadata *format, const psMetadata *defaults) 358 { 359 if (!format) { 360 format = conceptsCameraFormat(fpa, chip, cell); 361 if (!format) { 362 return false; 363 } 364 } 365 if (!defaults) { 366 defaults = conceptsDefaults(format); 367 if (!defaults) { 368 return false; 369 } 370 } 371 372 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(conceptItem->name, defaults, 373 fpa, chip, cell); 374 if (!defaultItem) { 375 return false; 376 } 377 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 378 format, fpa, chip, cell); 379 if (!formatted) { 380 return true; 381 } 382 383 if (strcmp(defaultItem->name, conceptItem->name) != 0) { 384 // Correct the name to match the concept name 385 defaultItem = psMetadataItemCopy(defaultItem); 386 psFree(defaultItem->name); 387 defaultItem->name = psStringCopy(conceptItem->name); 388 } else { 389 psMemIncrRefCounter(defaultItem); 390 } 391 392 if (!compareConcepts(formatted, defaultItem)) { 393 psWarning("Concept %s is specified by the DEFAULTS in the camera format, but the values don't match.", 394 conceptItem->name); 395 } 396 psFree(defaultItem); 397 psFree(formatted); 398 399 return true; 400 } 401 402 403 bool p_pmConceptWriteToHeader(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 404 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 405 const psMetadata *format, const psMetadata *translation) 406 { 407 if (!format) { 408 format = conceptsCameraFormat(fpa, chip, cell); 409 if (!format) { 410 return false; 411 } 412 } 413 if (!translation) { 414 translation = conceptsTranslation(format); 415 if (!translation) { 416 return false; 417 } 418 } 419 420 psMetadataItem *headerItem = psMetadataLookup(translation, conceptItem->name); // How to format for header 421 if (!headerItem) { 422 return false; 423 } 424 if (headerItem->type == PS_DATA_METADATA) { 425 // This is a menu 426 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", conceptItem->name); 427 headerItem = p_pmConceptsDepend(conceptItem->name, headerItem->data.md, translation, fpa, chip, cell); 428 if (!headerItem) { 429 return false; 430 } 431 } 432 if (headerItem->type != PS_DATA_STRING) { 433 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", conceptItem->name); 434 return false; 435 } 436 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", conceptItem->name, headerItem->data.str); 437 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 438 format, fpa, chip, cell); 439 if (!formatted) { 440 // Found it, but it doesn't need to be written 441 return true; 442 } 443 444 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU to which to write 245 445 if (!hdu) { 246 return false; 247 } 248 psMetadata *cameraFormat = hdu->format; // The camera format 249 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 250 psMetadataItem *specItem = NULL; // Item from the specs metadata 251 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 252 pmConceptSpec *spec = specItem->data.V; // The specification 253 psString name = specItem->name; // The concept name 254 psMetadataItem *cameraItem = psMetadataLookup(cell->config, name); // The concept from the camera, 255 // or NULL 256 if (cameraItem) { 257 // Grab the concept 258 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The concept 259 260 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 261 psStringAppend(&nameSource, "%s.SOURCE", name); 262 bool mdok = true; // Status of MD lookup 263 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 264 if (mdok && strlen(source) > 0) { 265 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 266 if (strcasecmp(source, "HEADER") == 0) { 267 if (cameraItem->type != PS_DATA_STRING) { 268 psWarning("Concept %s is specified by header, but is not " 269 "of type STR --- ignored.\n", conceptItem->name); 270 continue; 271 } 272 273 // Formatted version 274 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 275 cameraFormat, NULL, NULL, cell); 276 if (!formatted) { 277 continue; 278 } 279 280 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", name, cameraItem->data.str); 281 writeHeader(hdu, cameraItem->data.V, formatted); 282 psFree(formatted); 283 } else if (strcasecmp(source, "VALUE") == 0) { 284 // Formatted version 285 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 286 cameraFormat, NULL, NULL, cell); 287 if (!formatted) { 288 continue; 289 } 290 291 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", name); 292 if (! compareConcepts(formatted, cameraItem)) { 293 psWarning("Concept %s is specified by value in the camera " 294 "format, but the values don't match.\n", name); 295 } 296 psFree(formatted); 297 } else { 298 psWarning("Concept source %s isn't HEADER or VALUE --- can't " 299 "write\n", nameSource); 300 } 301 } else { 302 // Assume it's specified by value 303 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 304 cameraFormat, NULL, NULL, cell); 305 if (!formatted) { 306 continue; 307 } 308 309 if (! compareConcepts(formatted, cameraItem)) { 310 psWarning("Concept %s is specified by value in the camera " 311 "format, but the values don't match.\n", name); 312 } 313 psFree(formatted); 314 } 315 psFree(nameSource); 316 } 317 318 } 319 psFree(specsIter); 446 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU to write concept %s", conceptItem->name); 447 return false; 448 } 449 writeHeader(hdu, headerItem->data.V, formatted); 450 psFree(formatted); 451 320 452 return true; 321 453 } 322 454 323 bool p_pmConceptsWriteToDefaults(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 324 const pmCell *cell, const psMetadata *concepts) 325 { 326 PS_ASSERT_PTR_NON_NULL(specs, false); 327 PS_ASSERT_PTR_NON_NULL(concepts, false); 328 329 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 330 if (!hdu) { 331 return false; 332 } 333 psMetadata *cameraFormat = hdu->format; // The camera format 334 bool mdok = true; // Status of MD lookup 335 psMetadata *defaults = psMetadataLookupMetadata(&mdok, cameraFormat, "DEFAULTS"); // The DEFAULTS spec 336 if (!mdok || !defaults) { 337 return false; 338 } 339 340 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 341 psMetadataItem *specItem = NULL; // Item from the specs metadata 342 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 343 pmConceptSpec *spec = specItem->data.V; // The specification 344 psString name = specItem->name; // The concept name 345 346 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(name, defaults, fpa, chip, cell); 347 if (!defaultItem) { 348 continue; 349 } 350 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 351 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 352 cameraFormat, fpa, chip, cell); 353 if (!formatted) { 354 continue; 355 } 356 357 if (strcmp(defaultItem->name, name) != 0) { 358 // Correct the name to match the concept name 359 defaultItem = psMetadataItemCopy(defaultItem); 360 psFree(defaultItem->name); 361 defaultItem->name = psStringCopy(name); 362 } else { 363 psMemIncrRefCounter(defaultItem); 364 } 365 366 if (!compareConcepts(formatted, defaultItem)) { 367 psWarning("Concept %s is specified by the DEFAULTS in the camera " 368 "format, but the values don't match.\n", name); 369 } 370 psFree(defaultItem); 371 psFree(formatted); 372 } 373 psFree(specsIter); 455 bool p_pmConceptWriteToDatabase(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 456 pmConfig *config, const pmConceptSpec *spec, 457 const psMetadataItem *conceptItem, const psMetadata *format, 458 const psMetadata *database) 459 { 460 PS_ASSERT_PTR_NON_NULL(config, false); 461 462 #ifndef HAVE_PSDB 463 return false; 464 #else 465 466 if (!format) { 467 format = conceptsCameraFormat(fpa, chip, cell); 468 if (!format) { 469 return false; 470 } 471 } 472 if (!database) { 473 database = conceptsDatabase(format); 474 if (!database) { 475 return false; 476 } 477 } 478 479 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(conceptItem->name, database, config, 480 fpa, chip, cell); // Database version 481 if (!dbItem) { 482 return false; 483 } 484 485 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE, 486 format, fpa, chip, cell); 487 if (!formatted) { 488 return false; 489 } 490 491 if (strcmp(dbItem->name, conceptItem->name) != 0) { 492 // Correct the name to match the concept name 493 dbItem = psMetadataItemCopy(dbItem); 494 psFree(dbItem->name); 495 dbItem->name = psStringCopy(conceptItem->name); 496 } else { 497 psMemIncrRefCounter(dbItem); 498 } 499 500 if (!compareConcepts(formatted, dbItem)) { 501 psWarning("Concept %s is specified by the DATABASE in the camera " 502 "format, but the values don't match.\n", conceptItem->name); 503 } 504 psFree(dbItem); 505 psFree(formatted); 506 374 507 return true; 375 } 376 377 378 bool p_pmConceptsWriteToHeader(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 379 const pmCell *cell, const psMetadata *concepts) 380 { 381 PS_ASSERT_PTR_NON_NULL(specs, false); 382 PS_ASSERT_PTR_NON_NULL(concepts, false); 383 384 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 385 if (!hdu) { 386 return false; 387 } 388 psMetadata *cameraFormat = hdu->format; // The camera format 389 bool mdok = true; // Status of MD lookup 390 psMetadata *translation = psMetadataLookupMetadata(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec 391 if (!mdok || !translation) { 392 return false; 393 } 394 395 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 396 psMetadataItem *specItem = NULL; // Item from the specs metadata 397 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 398 pmConceptSpec *spec = specItem->data.V; // The specification 399 psString name = specItem->name; // The concept name 400 psMetadataItem *headerItem = psMetadataLookup(translation, name); // The item from the TRANSLATION 401 if (!headerItem) { 402 continue; 403 } 404 if (headerItem->type == PS_DATA_METADATA) { 405 // This is a menu 406 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", name); 407 headerItem = p_pmConceptsDepend(name, headerItem->data.md, translation, fpa, chip, cell); 408 if (!headerItem) { 409 continue; 410 } 411 } 412 if (headerItem->type != PS_DATA_STRING) { 413 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", name); 414 continue; 415 } 416 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", name, headerItem->data.str); 417 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 418 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 419 cameraFormat, fpa, chip, cell); 420 if (!formatted) { 421 continue; 422 } 423 writeHeader(hdu, headerItem->data.V, formatted); 424 psFree(formatted); 425 } 426 psFree(specsIter); 508 #endif 509 } 510 511 512 bool pmConceptWriteSingle(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 513 pmConfig *config, const psMetadataItem *conceptItem) 514 { 515 pmConceptsInit(); 516 517 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 518 if (!format) { 519 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 520 return false; 521 } 522 523 const char *name = conceptItem->name; // Name of concept 524 525 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications for FPA 526 bool mdok; // Status of MD lookup 527 pmConceptSpec *spec = psMetadataLookupPtr(&mdok, conceptsFPA, name); // Concept specification of interest 528 if (!spec) { 529 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications for Chip 530 spec = psMetadataLookupPtr(&mdok, conceptsChip, name); 531 if (!spec) { 532 psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications for Cell 533 spec = psMetadataLookupPtr(&mdok, conceptsCell, name); 534 if (!spec) { 535 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find specification for concept %s", name); 536 return false; 537 } 538 } 539 } 540 541 if (!p_pmConceptWriteToCells(cell, spec, conceptItem, format) && 542 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, conceptItem, format, NULL) && 543 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, conceptItem, format, NULL) && 544 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, conceptItem, format, NULL)) { 545 return false; 546 } 427 547 return true; 428 548 } 429 430 // XXX Warning: This code has not been tested at all431 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,432 const pmCell *cell, pmConfig *config, const psMetadata *concepts)433 {434 PS_ASSERT_PTR_NON_NULL(specs, false);435 PS_ASSERT_PTR_NON_NULL(concepts, false);436 PS_ASSERT_PTR_NON_NULL(config, false);437 438 #ifndef HAVE_PSDB439 return false;440 #else441 442 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level443 if (!hdu) {444 return false;445 }446 psMetadata *cameraFormat = hdu->format; // The camera format447 bool mdok = true; // Status of MD lookup448 psMetadata *database = psMetadataLookupMetadata(&mdok, cameraFormat, "DATABASE"); // The DATABASE spec449 if (!mdok || !database) {450 return false;451 }452 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator453 psMetadataItem *specItem = NULL; // Item from the specs metadata454 while ((specItem = psMetadataGetAndIncrement(specsIter))) {455 pmConceptSpec *spec = specItem->data.V; // The specification456 psString name = specItem->name; // The concept name457 458 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, config, fpa, chip, cell);459 if (!dbItem) {460 continue;461 }462 463 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts464 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,465 cameraFormat, fpa, chip, cell);466 if (!formatted) {467 continue;468 }469 470 if (strcmp(dbItem->name, name) != 0) {471 // Correct the name to match the concept name472 dbItem = psMetadataItemCopy(dbItem);473 psFree(dbItem->name);474 dbItem->name = psStringCopy(name);475 } else {476 psMemIncrRefCounter(dbItem);477 }478 479 if (!compareConcepts(formatted, dbItem)) {480 psWarning("Concept %s is specified by the DATABASE in the camera "481 "format, but the values don't match.\n", name);482 }483 psFree(dbItem);484 psFree(formatted);485 }486 psFree(specsIter);487 return true;488 #endif489 }490 491 492 493 549 494 550 … … 498 554 const pmChip *chip, // The chip 499 555 const pmCell *cell, // The cell 500 pmConceptSource source, // The source of the concepts to write501 556 pmConfig *config, // Configuration 502 557 psMetadata *concepts // The concepts to write out … … 508 563 pmConceptsInit(); 509 564 510 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p): %d\n", fpa, chip, cell, source); 511 512 if (source & PM_CONCEPT_SOURCE_CELLS) { 513 p_pmConceptsWriteToCells(*specs, cell, concepts); 514 } 515 if (source & PM_CONCEPT_SOURCE_DEFAULTS) { 516 p_pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts); 517 } 518 if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) { 519 p_pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts); 520 } 521 if (source & PM_CONCEPT_SOURCE_DATABASE) { 522 p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts); 523 } 565 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p)\n", fpa, chip, cell); 566 567 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 568 if (!format) { 569 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 570 return false; 571 } 572 573 psMetadata *defaults = conceptsDefaults(format); // DEFAULTS configuration 574 psMetadata *translation = conceptsTranslation(format); // TRANSLATION configuration 575 psMetadata *database = conceptsDatabase(format); // DATABASE configuration 576 577 psMetadataIterator *iter = psMetadataIteratorAlloc(*specs, PS_LIST_HEAD, NULL); // Iterator 578 psMetadataItem *item = NULL; // Item from the specs metadata 579 while ((item = psMetadataGetAndIncrement(iter))) { 580 pmConceptSpec *spec = item->data.V; // The specification 581 psString name = item->name; // The concept name 582 583 psMetadataItem *concept = psMetadataLookup(concepts, name); // Concept to write 584 585 if (!p_pmConceptWriteToCells(cell, spec, concept, format) && 586 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, concept, format, defaults) && 587 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, concept, format, translation) && 588 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, concept, format, database)) { 589 psTrace("psModules.concepts", 1, "Unable to write concept %s to any output", name); 590 } 591 } 592 psFree(iter); 524 593 525 594 return true; … … 527 596 528 597 529 bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source,bool propagateDown, pmConfig *config)598 bool pmConceptsWriteFPA(const pmFPA *fpa, bool propagateDown, pmConfig *config) 530 599 { 531 600 PS_ASSERT_PTR_NON_NULL(fpa, false); 532 601 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 533 602 psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts); 534 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source,config, fpa->concepts);603 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, config, fpa->concepts); 535 604 if (propagateDown) { 536 605 psArray *chips = fpa->chips; // Array of chips … … 538 607 pmChip *chip = chips->data[i]; // Chip of interest 539 608 if (chip && !chip->hdu) { 540 success &= pmConceptsWriteChip(chip, source,false, true, config);609 success &= pmConceptsWriteChip(chip, false, true, config); 541 610 } 542 611 } … … 546 615 547 616 548 bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp, 549 bool propagateDown, pmConfig *config) 617 bool pmConceptsWriteChip(const pmChip *chip, bool propagateUp, bool propagateDown, pmConfig *config) 550 618 { 551 619 PS_ASSERT_PTR_NON_NULL(chip, false); … … 553 621 psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts); 554 622 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 555 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source,config, chip->concepts);623 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, config, chip->concepts); 556 624 if (propagateUp && !fpa->hdu) { 557 625 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 558 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source,config, fpa->concepts);626 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, config, fpa->concepts); 559 627 } 560 628 if (propagateDown) { … … 563 631 pmCell *cell = cells->data[i]; // Cell of interest 564 632 if (cell && !cell->hdu) { 565 success &= pmConceptsWriteCell(cell, source,false, config);633 success &= pmConceptsWriteCell(cell, false, config); 566 634 } 567 635 } … … 571 639 572 640 573 bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source,bool propagateUp, pmConfig *config)641 bool pmConceptsWriteCell(const pmCell *cell, bool propagateUp, pmConfig *config) 574 642 { 575 643 PS_ASSERT_PTR_NON_NULL(cell, false); … … 579 647 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 580 648 581 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source,config, cell->concepts);649 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, config, cell->concepts); 582 650 if (propagateUp) { 583 651 if (!chip->hdu) { 584 652 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications 585 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source,config, chip->concepts);653 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, config, chip->concepts); 586 654 if (!fpa->hdu) { 587 655 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 588 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source,config, fpa->concepts);656 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, config, fpa->concepts); 589 657 } 590 658 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsWrite.h
r22699 r23594 20 20 /// @{ 21 21 22 /// "Write" concept sto (actually, check against) the camera format file's CELLS.22 /// "Write" concept to (actually, check against) the camera format file's CELLS. 23 23 /// 24 24 /// Examines the CELLS metadata in the camera format file for the current type of cell, and checks that the 25 /// concept s as defined there match the ones defined in the cell. A warning is produced if the concepts do25 /// concept as defined there match the ones defined in the cell. A warning is produced if the concept does 26 26 /// not match. 27 bool p_pmConceptsWriteToCells(const psMetadata *specs, ///< The concept specifications 27 bool p_pmConceptWriteToCells(const pmCell *cell, ///< The cell 28 const pmConceptSpec *spec, ///< Concept specification 29 const psMetadataItem *conceptItem, ///< Concept to write 30 const psMetadata *format ///< Camera format, or NULL 31 ); 32 33 /// "Write" concept to (actually, check against) the camera format file's DEFAULTS. 34 /// 35 /// Examines the DEFAULTS metadata in the camera format file, and checks that the concept as defined there 36 /// match the one defined in the cell. A warning is produced if the concept does not match. 37 bool p_pmConceptWriteToDefaults(const pmFPA *fpa, ///< The FPA 38 const pmChip *chip, ///< The chip 39 const pmCell *cell, ///< The cell 40 const pmConceptSpec *spec, ///< Concept specification 41 const psMetadataItem *conceptItem, ///< Concept to write 42 const psMetadata *format, ///< Camera format, or NULL 43 const psMetadata *defaults ///< DEFAULTS configuration, or NULL 44 ); 45 46 /// "Write" concept to (actually, add to, pending a later write) the FITS header. 47 /// 48 /// Examines the FITS header TRANSLATION metadata in the camera format file, and writes concept to the 49 /// appropriate FITS header(s) in the HDU, in preparation for a future write of the HDU. 50 bool p_pmConceptWriteToHeader(const pmFPA *fpa, ///< The FPA 51 const pmChip *chip, ///< The chip 28 52 const pmCell *cell, ///< The cell 29 const psMetadata *concepts ///< The concepts 30 ); 53 const pmConceptSpec *spec, ///< Concept specification 54 const psMetadataItem *conceptItem, ///< Concept to write 55 const psMetadata *format, ///< Camera format, or NULL 56 const psMetadata *translation ///< TRANSLATION configuration, or NULL 57 ); 31 58 32 /// "Write" concepts to (actually, check against) the camera format file's DEFAULTS.59 /// Write concept to the database. 33 60 /// 34 /// Examines the DEFAULTS metadata in the camera format file, and checks that the concepts as defined there 35 /// match the ones defined in the cell. A warning is produced if the concepts do not match. 36 bool p_pmConceptsWriteToDefaults(const psMetadata *specs, ///< The concept specifications 37 const pmFPA *fpa, ///< The FPA 38 const pmChip *chip, ///< The chip 39 const pmCell *cell, ///< The cell 40 const psMetadata *concepts ///< The concepts 61 /// Examines the DATABASE metadata in the camera format file, and writes (actually, check against) 62 /// concept to the database. 63 bool p_pmConceptWriteToDatabase(const pmFPA *fpa, ///< The FPA 64 const pmChip *chip, ///< The chip 65 const pmCell *cell, ///< The cell 66 pmConfig *config, ///< Configuration 67 const pmConceptSpec *spec, ///< Concept specification 68 const psMetadataItem *conceptItem, ///< Concept to write 69 const psMetadata *format, ///< Camera format, or NULL 70 const psMetadata *database ///< DATABASE configuration, or NULL 41 71 ); 42 72 43 /// "Write" concepts to (actually, add to, pending a later write) the FITS header.44 ///45 /// Examines the FITS header TRANSLATION metadata in the camera format file, and writes concepts to the46 /// appropriate FITS headers in the HDU, in preparation for a future write of the HDU.47 bool p_pmConceptsWriteToHeader(const psMetadata *specs, ///< The concept specifications48 const pmFPA *fpa, ///< The FPA49 const pmChip *chip, ///< The chip50 const pmCell *cell, ///< The cell51 const psMetadata *concepts ///< The concepts52 );53 73 54 /// Write concepts to the database. 55 /// 56 /// Examines the DATABASE metadata in the camera format file, and writes concepts to the database. 57 /// Warning: This function has not been tested; use at your own risk. 58 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, ///< The concept specifications 59 const pmFPA *fpa, ///< The FPA 60 const pmChip *chip, ///< The chip 61 const pmCell *cell, ///< The cell 62 pmConfig *config,///< Configuration 63 const psMetadata *concepts ///< The concepts 64 ); 74 bool pmConceptWriteSingle(const pmFPA *fpa, ///< The FPA 75 const pmChip *chip, ///< The chip 76 const pmCell *cell, ///< The cell 77 pmConfig *config, ///< Configuration 78 const psMetadataItem *concept ///< Concept to write 79 ); 65 80 66 81 … … 70 85 /// written for all lower levels by iterating over the components. 71 86 bool pmConceptsWriteFPA(const pmFPA *fpa, ///< FPA for which to write concepts 72 pmConceptSource source, ///< Source for concepts73 87 bool propagateDown, ///< Propagate to lower levels? 74 88 pmConfig *config ///< Configuration … … 80 94 /// written for the FPA, and the cell level by iterating over the components. 81 95 bool pmConceptsWriteChip(const pmChip *chip, ///< Chip for which to write concepts 82 pmConceptSource source, ///< Source for concepts83 96 bool propagateUp,///< Propagate to higher levels? 84 97 bool propagateDown, ///< Propagate to lower levels? … … 92 105 /// only the parent of this cell). 93 106 bool pmConceptsWriteCell(const pmCell *cell, ///< FPA for which to write concepts 94 pmConceptSource source, ///< Source for concepts95 107 bool propagateUp, ///< Propagate to higher levels? 96 108 pmConfig *config ///< Configuration -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfig.c
r23351 r23594 806 806 pmConfigLoadRecipeOptions(argc, argv, config, "-Df"); 807 807 pmConfigLoadRecipeOptions(argc, argv, config, "-Db"); 808 809 if (!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CL)) { 810 psError(PS_ERR_IO, false, "Failed to read recipes from command-line"); 811 psFree(config); 812 return NULL; 813 } 808 814 809 815 // Look for command-line options for files to replace -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigCamera.c
r23351 r23594 159 159 // Don't update these skycell concepts; last one MUST be 0 (i.e., NULL). 160 160 const static char *skycellConceptsCell[] = { "CELL.BIASSEC", "CELL.TRIMSEC", "CELL.READDIR", "CELL.XPARITY", 161 "CELL.YPARITY", "CELL.X0", "CELL.Y0", 0 };161 "CELL.YPARITY", "CELL.X0", "CELL.Y0", "CELL.TIMESYS", 0 }; 162 162 const static char *skycellConceptsChip[] = { "CHIP.XPARITY", "CHIP.YPARITY", 0 }; 163 const static char *skycellConceptsFPA[] = { 0};163 const static char *skycellConceptsFPA[] = { "FPA.TIMESYS" }; 164 164 165 165 // What do we call the skycell concept in the FITS header? … … 332 332 psMetadataAddS32(defaults, PS_LIST_TAIL, "CHIP.X0", 0, NULL, 0); 333 333 psMetadataAddS32(defaults, PS_LIST_TAIL, "CELL.READDIR", 0, "Read direction (rows)", 1); 334 psMetadataAddStr(defaults, PS_LIST_TAIL, "CELL.TIMESYS", 0, "Time system", "TAI"); 335 psMetadataAddStr(defaults, PS_LIST_TAIL, "FPA.TIMESYS", 0, "Time system", "TAI"); 334 336 335 337 psMetadataAddMetadata(format, PS_LIST_TAIL, "DEFAULTS", 0, "Default values for concepts", defaults); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigMask.c
r21386 r23594 10 10 11 11 static pmConfigMaskInfo masks[] = { 12 { "DETECTOR", NULL, 0x00, true }, // Something is wrong with the detector 13 { "DARK", "DETECTOR", 0x00, true }, // Pixel doesn't dark-subtract properly 14 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 15 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 16 { "RANGE", NULL, 0x00, true }, // Pixel is out-of-range of linearity 17 { "SAT", "RANGE", 0x01, true }, // Pixel is saturated 18 { "BAD", "RANGE", 0x01, true }, // Pixel is low 19 { "BAD.WARP", NULL, 0x01, true }, // Pixel is bad after convolution with a bad pixel 20 { "CR", NULL, 0x00, true }, // Pixel contains a cosmic ray 21 { "GHOST", NULL, 0x00, true }, // Pixel contains an optical ghost 22 { "POOR.WARP", NULL, 0x00, false }, // Pixel is poor after convolution with a bad pixel 23 // "LOW" Pixel is low 24 // "CONV" Pixel is bad after convolution with a bad pixel 12 // Features of the detector 13 { "DETECTOR", NULL, 0x01, true }, // Something is wrong with the detector 14 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 15 { "DARK", "DETECTOR", 0x01, true }, // Pixel doesn't dark-subtract properly 16 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 17 { "CTE", "DETECTOR", 0x01, true }, // Pixel has poor CTE 18 // Invalid signal ranges 19 { "SAT", NULL, 0x02, true }, // Pixel is saturated or non-linear 20 { "LOW", "SAT", 0x02, true }, // Pixel is low 21 { "SUSPECT", NULL, 0x04, false }, // Pixel is suspected of being bad 22 // Non-astronomical structures 23 { "CR", NULL, 0x08, true }, // Pixel contains a cosmic ray 24 { "SPIKE", NULL, 0x08, true }, // Pixel contains a diffraction spike 25 { "GHOST", NULL, 0x08, true }, // Pixel contains an optical ghost 26 { "STREAK", NULL, 0x08, true }, // Pixel contains streak data 27 { "STARCORE", NULL, 0x08, true }, // Pixel contains a bright star core 28 // Effects of convolution and interpolation 29 { "CONV.BAD", NULL, 0x02, true }, // Pixel is bad after convolution with a bad pixel 30 { "CONV.POOR", NULL, 0x04, false }, // Pixel is poor after convolution with a bad pixel 25 31 }; 26 32 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRun.c
r23351 r23594 39 39 } 40 40 41 42 bool pmConfigRunFileAdd(pmConfig *config, const pmFPAfile *file) 41 // Add a file to a nominated metadata in the RUN information 42 static bool configRunFileAdd(pmConfig *config, // Configuration 43 const pmFPAfile *file, // File to add 44 const char *target // Name of metadata to which to add 45 ) 43 46 { 44 47 PS_ASSERT_PTR_NON_NULL(config, false); … … 47 50 psMetadata *run = configRun(config);// RUN information 48 51 psAssert(run, "Require run-time information"); 49 psMetadata *files = configElement(run, "FILES", "Filerules used during execution");52 psMetadata *files = configElement(run, target, "Filerules used during execution"); 50 53 psAssert(files, "Require list of files"); 51 54 … … 71 74 } 72 75 73 psArray *pmConfigRunFileGet(pmConfig *config, const char *name)76 bool pmConfigRunFileAddRead(pmConfig *config, const pmFPAfile *file) 74 77 { 75 78 PS_ASSERT_PTR_NON_NULL(config, false); 76 PS_ASSERT_ STRING_NON_EMPTY(name, false);79 PS_ASSERT_PTR_NON_NULL(file, false); 77 80 81 return configRunFileAdd(config, file, "FILES.INPUT"); 82 } 83 84 bool pmConfigRunFileAddWrite(pmConfig *config, const pmFPAfile *file) 85 { 86 PS_ASSERT_PTR_NON_NULL(config, false); 87 PS_ASSERT_PTR_NON_NULL(file, false); 88 89 return configRunFileAdd(config, file, "FILES.OUTPUT"); 90 } 91 92 // Get an array of filenames from the nominated RUN information 93 static psArray *configRunFileGet(pmConfig *config, // Configuration 94 const char *name, // Name of file 95 const char *source // Source metadata for file 96 ) 97 { 78 98 psMetadata *run = configRun(config);// RUN information 79 99 psAssert(run, "Require run-time information"); 80 psMetadata *files = configElement(run, "FILES", "Filerules used during execution");100 psMetadata *files = configElement(run, source, "Filerules used during execution"); 81 101 psAssert(files, "Require list of files"); 102 103 if (psListLength(files->list) == 0) { 104 // Can't find anything 105 return NULL; 106 } 82 107 83 108 psList *list = psListAlloc(NULL); // List of file names … … 104 129 105 130 return array; 131 } 132 133 134 psArray *pmConfigRunFileGet(pmConfig *config, const char *name) 135 { 136 PS_ASSERT_PTR_NON_NULL(config, false); 137 PS_ASSERT_STRING_NON_EMPTY(name, false); 138 139 // Try the input and output, in turn 140 psArray *files = configRunFileGet(config, name, "FILES.INPUT"); // Files from RUN metadata 141 if (!files) { 142 configRunFileGet(config, name, "FILES.OUTPUT"); 143 } 144 145 return files; 106 146 } 107 147 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRun.h
r23351 r23594 6 6 #include <pmFPAfile.h> 7 7 8 /// Add a file to the list of files used in the run-time information 9 bool pmConfigRunFileAdd( 8 /// Add a file to the list of files read in the run-time information 9 bool pmConfigRunFileAddRead( 10 pmConfig *config, ///< Configuration 11 const pmFPAfile *file ///< File to add 12 ); 13 14 /// Add a file to the list of files written in the run-time information 15 bool pmConfigRunFileAddWrite( 10 16 pmConfig *config, ///< Configuration 11 17 const pmFPAfile *file ///< File to add -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendDB.h
r23351 r23594 63 63 64 64 pmDetrendSelectOptions *pmDetrendSelectOptionsAlloc(const char *camera, psTime time, pmDetrendType type); 65 pmDetrendSelectResults *pmDetrendSelectResultsAlloc( );65 pmDetrendSelectResults *pmDetrendSelectResultsAlloc(void); 66 66 pmDetrendSelectResults *pmDetrendSelect (const pmDetrendSelectOptions *options, const pmConfig *config); 67 67 char *pmDetrendFile (const char *detID, const char *classID, const pmConfig *config); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendThreads.h
r18893 r23594 18 18 19 19 /// get the requested number of scan rows per thread 20 int pmDetrendGetScanRows ();20 int pmDetrendGetScanRows(void); 21 21 22 22 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmShutterCorrection.c
r23351 r23594 71 71 } 72 72 73 pmShutterCorrection *pmShutterCorrectionAlloc( )73 pmShutterCorrection *pmShutterCorrectionAlloc(void) 74 74 { 75 75 pmShutterCorrection *corr = (pmShutterCorrection*)psAlloc(sizeof(pmShutterCorrection)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmShutterCorrection.h
r21509 r23594 69 69 70 70 /// Allocator for shutter correction parameters 71 pmShutterCorrection *pmShutterCorrectionAlloc( );71 pmShutterCorrection *pmShutterCorrectionAlloc(void); 72 72 73 73 /// Guess a shutter correction, based on plot of counts vs exposure time -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmKapaPlots.c
r13896 r23594 47 47 } 48 48 49 bool pmKapaClose ( )49 bool pmKapaClose (void) 50 50 { 51 51 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmKapaPlots.h
r12696 r23594 1 1 /* @file pmKapaPlots.h 2 * @brief functions to make plots with the external program 'kapa' 2 * @brief functions to make plots with the external program 'kapa' 3 3 * 4 4 * @author EAM, IfA … … 17 17 // move to psLib or psModules 18 18 int pmKapaOpen (bool showWindow); 19 bool pmKapaClose ();19 bool pmKapaClose(void); 20 20 bool pmKapaPlotVectorPair (psVector *xVec, psVector *yVec); 21 21 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/psPipe.c
r12888 r23594 35 35 } 36 36 37 psPipe *psPipeAlloc ( )37 psPipe *psPipeAlloc (void) 38 38 { 39 39 psPipe *pipe = (psPipe *)psAlloc(sizeof(psPipe)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/psPipe.h
r11253 r23594 1 1 /* @file psPipe.h 2 * @brief 3-stream pipe 2 * @brief 3-stream pipe 3 3 * 4 4 * @author EAM, IfA … … 26 26 27 27 // psPipe functions 28 psPipe *psPipeAlloc ( );28 psPipe *psPipeAlloc (void); 29 29 psPipe *psPipeOpen (char *command); 30 30 int psPipeClose (psPipe *pipe); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmStack.c
r23351 r23594 46 46 psVector *weights; // Pixel weightings 47 47 psVector *sources; // Pixel sources (which image did they come from?) 48 psVector *limits; // Rejection limits 48 49 psVector *sort; // Buffer for sorting (to get a robust estimator of the standard dev) 49 50 } combineBuffer; … … 56 57 psFree(buffer->weights); 57 58 psFree(buffer->sources); 59 psFree(buffer->limits); 58 60 psFree(buffer->sort); 59 61 return; … … 71 73 buffer->weights = psVectorAlloc(numImages, PS_TYPE_F32); 72 74 buffer->sources = psVectorAlloc(numImages, PS_TYPE_U16); 75 buffer->limits = psVectorAlloc(numImages, PS_TYPE_F32); 73 76 buffer->sort = psVectorAlloc(numImages, PS_TYPE_F32); 74 77 return buffer; … … 319 322 bool useVariance, // Use variance for rejection when combining? 320 323 bool safe, // Combine safely? 324 bool rejectInspect, // Reject values marked for inspection from combination? 321 325 combineBuffer *buffer // Buffer for combination; to avoid multiple allocations 322 326 ) … … 336 340 psVector *pixelWeights = buffer->weights; // Image weights for the pixel of interest 337 341 psVector *pixelSources = buffer->sources; // Sources for the pixel of interest 342 psVector *pixelLimits = buffer->limits; // Limits for the pixel of interest 338 343 psVector *sort = buffer->sort; // Sort buffer 339 344 … … 375 380 pixelWeights->n = num; 376 381 pixelSources->n = num; 382 pixelLimits->n = num; 377 383 378 384 #ifdef TESTING … … 389 395 // Default option is that the pixel is bad 390 396 float imageValue = NAN, varianceValue = NAN; // Value for combined image and variance map 391 psImageMaskType maskValue = bad; // Value for combined mask397 psImageMaskType maskValue = bad; // Value for combined mask 392 398 switch (num) { 393 399 case 0: … … 449 455 if (PS_SQR(diff) > PS_SQR(rej) * sigma2) { 450 456 // Not consistent: mark both for inspection 451 combineInspect(inputs, x, y, pixelSources->data.U16[0]); 452 combineInspect(inputs, x, y, pixelSources->data.U16[1]); 457 if (rejectInspect) { 458 imageValue = NAN; 459 varianceValue = NAN; 460 maskValue = bad; 461 } else { 462 combineInspect(inputs, x, y, pixelSources->data.U16[0]); 463 combineInspect(inputs, x, y, pixelSources->data.U16[1]); 464 } 453 465 #ifdef TESTING 454 466 if (x == TEST_X && y == TEST_Y) { … … 501 513 #endif 502 514 503 pixel Variances->data.F32[i] = rej2 * (pixelVariances->data.F32[i] + sysVar);515 pixelLimits->data.F32[i] = rej2 * (pixelVariances->data.F32[i] + sysVar); 504 516 } 505 517 } … … 541 553 #define MASK_PIXEL_FOR_INSPECTION() \ 542 554 pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; \ 543 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 555 if (!rejectInspect) { \ 556 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 557 } \ 544 558 numClipped++; \ 545 559 totalClipped++; … … 553 567 // Comparing squares --- cheaper than lots of sqrts 554 568 // pixelVariances includes the rejection limit, from above 555 if (PS_SQR(diff) > pixel Variances->data.F32[j]) {569 if (PS_SQR(diff) > pixelLimits->data.F32[j]) { 556 570 MASK_PIXEL_FOR_INSPECTION(); 557 571 #ifdef TESTING 558 572 if (x == TEST_X && y == TEST_Y) { 559 573 fprintf(stderr, "Rejecting input %d based on variance: %f > %f\n", 560 j, diff, sqrtf(pixel Variances->data.F32[j]));574 j, diff, sqrtf(pixelLimits->data.F32[j])); 561 575 } 562 576 #endif … … 573 587 } 574 588 } 589 590 if (rejectInspect && totalClipped > 0) { 591 // Get rid of the masked values 592 // The alternative to this is to make combinationMeanVariance() accept a mask 593 int good = 0; // Index of good value 594 for (int i = 0; i < num; i++) { 595 if (pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 596 continue; 597 } 598 if (i != good) { 599 pixelData->data.F32[good] = pixelData->data.F32[i]; 600 pixelVariances->data.F32[good] = pixelVariances->data.F32[i]; 601 pixelWeights->data.F32[good] = pixelWeights->data.F32[i]; 602 pixelData->data.F32[good] = pixelData->data.F32[i]; 603 } 604 good++; 605 } 606 pixelData->n = good; 607 pixelVariances->n = good; 608 pixelWeights->n = good; 609 if (combinationMeanVariance(&mean, &var, pixelData, pixelVariances, pixelWeights)) { 610 imageValue = mean; 611 varianceValue = var; 612 maskValue = 0; 613 } else { 614 imageValue = NAN; 615 varianceValue = NAN; 616 maskValue = bad; 617 } 618 } 619 575 620 break; 576 621 } … … 734 779 bool pmStackCombine(pmReadout *combined, psArray *input, psImageMaskType maskVal, psImageMaskType bad, 735 780 int kernelSize, int numIter, float rej, float sys, float discard, 736 bool entire, bool useVariance, bool safe )781 bool entire, bool useVariance, bool safe, bool rejectInspect) 737 782 { 738 783 PS_ASSERT_PTR_NON_NULL(combined, false); … … 838 883 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 839 884 addVariance, reject, x, y, maskVal, bad, numIter, rej, sys, discard, 840 useVariance, safe, buffer);885 useVariance, safe, rejectInspect, buffer); 841 886 } 842 887 } … … 853 898 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 854 899 addVariance, reject, x, y, maskVal, bad, numIter, rej, sys, discard, 855 useVariance, safe, buffer);900 useVariance, safe, rejectInspect, buffer); 856 901 } 857 902 } … … 881 926 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 882 927 addVariance, NULL, x, y, maskVal, bad, numIter, rej, sys, discard, 883 useVariance, safe, buffer);928 useVariance, safe, rejectInspect, buffer); 884 929 } 885 930 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmStack.h
r21476 r23594 52 52 bool entire, ///< Combine entire image even if rejection lists provided? 53 53 bool useVariance, ///< Use variance values for rejection? 54 bool safe ///< Play safe with small numbers of input pixels (mask if N <= 2)? 54 bool safe, ///< Play safe with small numbers of input pixels (mask if N <= 2)? 55 bool rejectInspect ///< Reject pixels instead of marking them for inspection? 55 56 ); 56 57 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionIO.c
r23351 r23594 4 4 5 5 #include "pmHDU.h" 6 #include "pmHDUUtils.h" 6 7 #include "pmFPA.h" 7 8 #include "pmFPAview.h" … … 143 144 psMetadata *header = psMetadataAlloc(); // Header for FITS file 144 145 146 pmCell *cell = ro->parent; // Cell of interest 147 if (cell) { 148 pmChip *chip = cell->parent; // Chip of interest 149 pmFPA *fpa = chip->parent; // FPA of interest 150 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // HDU for readout 151 if (hdu) { 152 header = psMetadataCopy(header, hdu->header); 153 } 154 } 155 145 156 // CVS tags, used to identify the version of this file (in case incompatibilities are introduced) 146 157 psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $"); … … 533 544 return true; 534 545 } 535 if (file->fileLevel != PM_FPA_LEVEL_FPA) {536 return true;537 }538 if (file->fpa->chips->n == 1) {539 return true;540 }541 546 542 547 // find the FPA phu -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.c
r23351 r23594 44 44 45 45 /** destroy windows at the end of a run*/ 46 bool pmSubtractionVisualClose( )46 bool pmSubtractionVisualClose(void) 47 47 { 48 48 if(kapa != -1) … … 256 256 257 257 #else 258 bool pmSubtractionVisualClose( ) {return true;}258 bool pmSubtractionVisualClose(void) {return true;} 259 259 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) {return true;} 260 260 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro) {return true;} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.h
r23351 r23594 2 2 #define PM_SUBTRACTION_VISUAL_H 3 3 4 bool pmSubtractionVisualClose( );4 bool pmSubtractionVisualClose(void); 5 5 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels); 6 6 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmDetections.c
r18828 r23594 30 30 31 31 // generate a pmDetections container with empty (allocated) footprints and peaks containers 32 pmDetections *pmDetectionsAlloc( ) {32 pmDetections *pmDetectionsAlloc(void) { 33 33 34 34 pmDetections *detections = (pmDetections *)psAlloc(sizeof(pmDetections)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmDetections.h
r18828 r23594 20 20 */ 21 21 typedef struct { 22 psArray *footprints; // collection of footprints in the image23 psArray *peaks; // collection of all peaks contained by the footprints24 psArray *oldPeaks; // collection of all peaks previously found22 psArray *footprints; // collection of footprints in the image 23 psArray *peaks; // collection of all peaks contained by the footprints 24 psArray *oldPeaks; // collection of all peaks previously found 25 25 int last; 26 26 } pmDetections; 27 27 28 pmDetections *pmDetectionsAlloc ( );28 pmDetections *pmDetectionsAlloc (void); 29 29 30 30 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmMoments.c
r23351 r23594 25 25 to zero. 26 26 *****************************************************************************/ 27 pmMoments *pmMomentsAlloc( )27 pmMoments *pmMomentsAlloc(void) 28 28 { 29 29 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmMoments.h
r19879 r23594 53 53 * 54 54 */ 55 pmMoments *pmMomentsAlloc( );55 pmMoments *pmMomentsAlloc(void); 56 56 57 57 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmPSF.c
r20937 r23594 54 54 } 55 55 56 pmPSFOptions *pmPSFOptionsAlloc ( ) {56 pmPSFOptions *pmPSFOptionsAlloc (void) { 57 57 58 58 pmPSFOptions *options = (pmPSFOptions *) psAlloc(sizeof(pmPSFOptions)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmPSF.h
r21183 r23594 96 96 pmPSF *pmPSFAlloc (const pmPSFOptions *options); 97 97 bool psMemCheckPSF(psPtr ptr); 98 pmPSFOptions *pmPSFOptionsAlloc( );98 pmPSFOptions *pmPSFOptionsAlloc(void); 99 99 bool psMemCheckPSFOptions(psPtr ptr); 100 100 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSource.h
r23351 r23594 105 105 * 106 106 */ 107 pmSource *pmSourceAlloc( );107 pmSource *pmSourceAlloc(void); 108 108 109 109 /** pmSourceCopy() -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceExtendedPars.c
r21363 r23594 46 46 } 47 47 48 pmSourceExtendedPars *pmSourceExtendedParsAlloc ( ) {48 pmSourceExtendedPars *pmSourceExtendedParsAlloc (void) { 49 49 pmSourceExtendedPars *pars = (pmSourceExtendedPars *) psAlloc(sizeof(pmSourceExtendedPars)); 50 50 psMemSetDeallocator(pars, (psFreeFunc) pmSourceExtendedParsFree); … … 75 75 } 76 76 77 pmSourceRadialProfile *pmSourceRadialProfileAlloc ( ) {77 pmSourceRadialProfile *pmSourceRadialProfileAlloc (void) { 78 78 79 79 pmSourceRadialProfile *profile = (pmSourceRadialProfile *) psAlloc(sizeof(pmSourceRadialProfile)); … … 99 99 } 100 100 101 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc ( ) {101 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc (void) { 102 102 103 103 pmSourceIsophotalValues *isophot = (pmSourceIsophotalValues *) psAlloc(sizeof(pmSourceIsophotalValues)); … … 125 125 } 126 126 127 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc ( ) {127 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc (void) { 128 128 129 129 pmSourcePetrosianValues *petrosian = (pmSourcePetrosianValues *) psAlloc(sizeof(pmSourcePetrosianValues)); … … 150 150 } 151 151 152 pmSourceKronValues *pmSourceKronValuesAlloc ( ) {152 pmSourceKronValues *pmSourceKronValuesAlloc (void) { 153 153 154 154 pmSourceKronValues *kron = (pmSourceKronValues *) psAlloc(sizeof(pmSourceKronValues)); … … 181 181 } 182 182 183 pmSourceAnnuli *pmSourceAnnuliAlloc ( ) {183 pmSourceAnnuli *pmSourceAnnuliAlloc (void) { 184 184 185 185 pmSourceAnnuli *annuli = (pmSourceAnnuli *) psAlloc(sizeof(pmSourceAnnuli)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceExtendedPars.h
r21363 r23594 55 55 } pmSourceExtendedPars; 56 56 57 pmSourceExtendedPars *pmSourceExtendedParsAlloc ();57 pmSourceExtendedPars *pmSourceExtendedParsAlloc(void); 58 58 bool psMemCheckSourceExtendedPars(psPtr ptr); 59 pmSourceRadialProfile *pmSourceRadialProfileAlloc ();59 pmSourceRadialProfile *pmSourceRadialProfileAlloc(void); 60 60 bool psMemCheckSourceRadialProfile(psPtr ptr); 61 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc ();61 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc(void); 62 62 bool psMemCheckSourceIsophotalValues(psPtr ptr); 63 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc ();63 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc(void); 64 64 bool psMemCheckSourcePetrosianValues(psPtr ptr); 65 pmSourceKronValues *pmSourceKronValuesAlloc ();65 pmSourceKronValues *pmSourceKronValuesAlloc(void); 66 66 bool psMemCheckSourceKronValues(psPtr ptr); 67 pmSourceAnnuli *pmSourceAnnuliAlloc ();67 pmSourceAnnuli *pmSourceAnnuliAlloc(void); 68 68 bool psMemCheckSourceAnnuli(psPtr ptr); 69 69 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitSet.c
r23351 r23594 67 67 } 68 68 69 void pmSourceFitSetDone ( ) {69 void pmSourceFitSetDone (void) { 70 70 psFree (fitSets); 71 71 } … … 150 150 } 151 151 152 pmSourceFitSetData *pmSourceFitSetDataGet ( ) {152 pmSourceFitSetData *pmSourceFitSetDataGet (void) { 153 153 154 154 psAssert (fitSets, "pmSourceFitSetInit not called"); … … 172 172 } 173 173 174 void pmSourceFitSetDataClear ( ) {174 void pmSourceFitSetDataClear (void) { 175 175 176 176 int i; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitSet.h
r21183 r23594 24 24 // use this function to init the fit sets based on the number of threads 25 25 bool pmSourceFitSetInit (int nThreads); 26 void pmSourceFitSetDone ( );26 void pmSourceFitSetDone (void); 27 27 28 28 // initialize data for a group of object models … … 32 32 // functions for selecting the FitSet corresponding to the current thread 33 33 pmSourceFitSetData *pmSourceFitSetDataSet (psArray *modelSet); 34 pmSourceFitSetData *pmSourceFitSetDataGet ( );35 void pmSourceFitSetDataClear ( );34 pmSourceFitSetData *pmSourceFitSetDataGet (void); 35 void pmSourceFitSetDataClear (void); 36 36 37 37 // function used to set limits for a group of models … … 54 54 */ 55 55 bool pmSourceFitSet( 56 pmSource *source, ///< The input pmSource57 psArray *modelSet, ///< model to be fitted58 pmSourceFitMode mode, ///< define parameters to be fitted59 psImageMaskType maskVal ///< Vale to mask56 pmSource *source, ///< The input pmSource 57 psArray *modelSet, ///< model to be fitted 58 pmSourceFitMode mode, ///< define parameters to be fitted 59 psImageMaskType maskVal ///< Vale to mask 60 60 61 61 ); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourcePlots.c
r19849 r23594 139 139 } 140 140 141 pmSourcePlotLayout *pmSourcePlotLayoutAlloc( )141 pmSourcePlotLayout *pmSourcePlotLayoutAlloc(void) 142 142 { 143 143 pmSourcePlotLayout *layout = (pmSourcePlotLayout *)psAlloc(sizeof(pmSourcePlotLayout)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourcePlots.h
r15562 r23594 29 29 // typedef bool (*pmSourcePlotFunction)(pmConfig *config, pmFPAview *view, pmSourcePlotLayout *layout); 30 30 31 pmSourcePlotLayout *pmSourcePlotLayoutAlloc( );31 pmSourcePlotLayout *pmSourcePlotLayoutAlloc(void); 32 32 bool psMemCheckSourcePlotLayout(psPtr ptr); 33 33 -
branches/cnb_branches/cnb_branch_20090301/psastro
- Property svn:mergeinfo changed
/branches/eam_branches/eam_branch_20090312/psastro (added) merged: 23321-23322,23335-23337,23407 /trunk/psastro merged: 23412,23431,23486,23494,23584,23591-23592
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psastro/src
- Property svn:ignore
-
old new 16 16 gpcModel 17 17 psastroModelFit 18 psastroExtract
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/psastro/src/Makefile.am
r23352 r23594 10 10 # FORCE: ; 11 11 12 bin_PROGRAMS = psastro psastro Model psastroModelFit gpcModel12 bin_PROGRAMS = psastro psastroExtract psastroModel psastroModelFit gpcModel 13 13 14 14 psastro_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 15 15 psastro_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 16 16 psastro_LDADD = libpsastro.la 17 18 psastroExtract_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 19 psastroExtract_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 20 psastroExtract_LDADD = libpsastro.la 17 21 18 22 psastroModel_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) … … 35 39 psastroDataSave.c \ 36 40 psastroMetadataStats.c \ 41 psastroCleanup.c 42 43 psastroExtract_SOURCES = \ 44 psastroExtract.c \ 45 psastroExtractArguments.c \ 46 psastroExtractParseCamera.c \ 47 psastroExtractDataLoad.c \ 48 psastroExtractAnalysis.c \ 49 psastroExtractStar.c \ 50 psastroExtractStars.c \ 51 psastroExtractGhosts.c \ 52 psastroExtractFindChip.c \ 37 53 psastroCleanup.c 38 54 -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastro.h
r23352 r23594 58 58 bool psastroMaskUpdates (pmConfig *config); 59 59 60 psPlaneDistort *psPlaneDistortIdentity (); 61 bool psPlaneDistortIsIdentity (psPlaneDistort *distort); 62 63 psArray *psastroLoadRefstars (pmConfig *config); 60 psArray *psastroLoadRefstars (pmConfig *config, const char *source); 64 61 bool psastroChipAstrom (pmConfig *config); 65 62 bool psastroOneChip (pmFPA *fpa, pmChip *chip, psArray *refset, psArray *rawset, psMetadata *recipe, psMetadata *updates); 66 63 bool psastroOneChipGrid (pmFPA *fpa, pmChip *chip, psArray *refset, psArray *rawset, psMetadata *recipe, psMetadata *updates); 67 64 bool psastroOneChipFit (pmFPA *fpa, pmChip *chip, psArray *refset, psArray *rawset, psMetadata *recipe, psMetadata *updates); 68 bool psastroChooseRefstars (pmConfig *config, psArray *refs );65 bool psastroChooseRefstars (pmConfig *config, psArray *refs, const char *source); 69 66 bool psastroRefstarSubset (pmReadout *readout); 70 67 pmLumFunc *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc); … … 121 118 bool psastroDumpCorners (char *filenameU, char *filenameD, pmFPA *fpa); 122 119 120 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config, const char *source); 123 121 124 122 psArray *psastroReadGetstarCatalog (psFits *fits); … … 129 127 bool psastroMetadataStats (pmConfig *config); 130 128 131 bool psastroZeroPoint (pmConfig *config); 132 bool psastroZeroPointReadout(pmReadout *readout, float zeropt, float exptime); 133 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, pmFPA *fpa, psMetadata *recipe); 129 bool psastroZeroPoint (pmConfig *config); 130 bool psastroZeroPointReadout(pmReadout *readout, float zeropt, float exptime); 131 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, pmFPA *fpa, psMetadata *recipe); 132 133 // psastroExtract functions 134 bool psastroExtractAnalysis (pmConfig *config); 135 bool psastroExtractStars (pmConfig *config); 136 bool psastroExtractGhosts (pmConfig *config); 137 pmChip *psastroExtractFindChip (float *xChip, float *yChip, pmFPA *fpa, float xFPA, float yFPA); 138 bool psastroExtractChipBounds (pmFPA *fpa); 139 140 psImage *psastroExtractStar (psImage *input, float x, float y, float dX, float dY); 141 bool psastroExtractParseCamera (pmConfig *config); 142 bool psastroExtractDataLoad (pmConfig *config); 143 pmConfig *psastroExtractArguments (int argc, char **argv); 134 144 135 145 ///@} -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroAnalysis.c
r21409 r23594 45 45 46 46 // load the reference stars overlapping the data stars 47 psArray *refs = psastroLoadRefstars(config );47 psArray *refs = psastroLoadRefstars(config, "PSASTRO.INPUT"); 48 48 if (!refs) { 49 49 psError (PSASTRO_ERR_UNKNOWN, false, "failed to load reference data\n"); … … 56 56 } 57 57 58 if (!psastroChooseRefstars (config, refs )) {58 if (!psastroChooseRefstars (config, refs, "PSASTRO.INPUT")) { 59 59 psError (PSASTRO_ERR_UNKNOWN, false, "failed to select reference data for chips\n"); 60 60 psFree(refs); 61 61 return false; 62 62 } 63 psFree (refs); // refs of interest are saved on readout->analysis 63 64 64 65 // check the command-line arguments first … … 79 80 if (!psastroChipAstrom (config)) { 80 81 psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform single chip astrometry\n"); 81 psFree(refs);82 82 return false; 83 83 } … … 86 86 if (!psastroMosaicAstrom (config)) { 87 87 psError (PSASTRO_ERR_UNKNOWN, false, "failed to perform mosaic camera astrometry\n"); 88 psFree(refs);89 88 return false; 90 89 } … … 100 99 // psastroStackAstrom (config, refs); 101 100 102 psFree (refs);103 101 return true; 104 102 } -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroChooseRefstars.c
r21409 r23594 20 20 } 21 21 22 bool psastroChooseRefstars (pmConfig *config, psArray *refs ) {22 bool psastroChooseRefstars (pmConfig *config, psArray *refs, const char *source) { 23 23 24 24 bool status; … … 35 35 36 36 // select the input data sources 37 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");37 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, source); 38 38 if (!input) { 39 39 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n"); -
branches/cnb_branches/cnb_branch_20090301/psastro/src/psastroLoadRefstars.c
r21422 r23594 14 14 # define ELIXIR_MODE 1 15 15 16 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config); 17 18 psArray *psastroLoadRefstars (pmConfig *config) { 16 psArray *psastroLoadRefstars (pmConfig *config, const char *source) { 19 17 20 18 int fd; … … 69 67 float minMag; 70 68 float maxRho; 71 char *photcode = psastroSetMagLimit (&minMag, &maxRho, config );69 char *photcode = psastroSetMagLimit (&minMag, &maxRho, config, source); 72 70 PS_ASSERT (photcode, NULL); 73 71 … … 240 238 goto escape; } 241 239 242 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config ) {240 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config, const char *source) { 243 241 244 242 bool status; … … 249 247 250 248 // select the input data sources 251 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");249 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, source); 252 250 if (!input) { 253 251 psLogMsg ("psastro", PS_LOG_DETAIL, "no supplied reference header data"); -
branches/cnb_branches/cnb_branch_20090301/psconfig
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/eam_branches/eam_branch_20090312/psconfig 23313-23408
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psconfig/psbuild
r23352 r23594 14 14 $verbose = 0; 15 15 $use_svn = 1; 16 $svn_trunk = ""; 16 17 17 18 $extlibs = "none"; … … 34 35 if ($ARGV[0] eq "-extperl") { 35 36 $extperl = $ARGV[1]; 37 shift; shift; next; 38 } 39 if ($ARGV[0] eq "-trunk") { 40 $svn_trunk = $ARGV[1]; 36 41 shift; shift; next; 37 42 } … … 293 298 print "\033]0; ** psbuild: $module[$i] ** \007"; 294 299 300 if ($svn_trunk && (!-d $workdir || !-r $workdir || !-x $workdir)) { 301 # try trunk instead 302 print STDERR "$module[$i] missing from local path, trying trunk path\n"; 303 $workdir = "$svn_trunk/$module[$i]"; 304 } 305 295 306 if (!-d $workdir || !-r $workdir || !-x $workdir) { 296 307 print STDERR "WARNING: no directory for component $module[$i], skipping\n"; -
branches/cnb_branches/cnb_branch_20090301/psconfig/psconfig.csh.in
r18708 r23594 410 410 411 411 if ("$PSCONFIG" == "none") then 412 alias psconfigure configure413 alias psautogen autogen.sh412 alias psconfigure ./configure 413 alias psautogen ./autogen.sh 414 414 alias psperlbuild perl Build.PL 415 415 else -
branches/cnb_branches/cnb_branch_20090301/psconfig/tagsets/ipp-2.8.dist
r23352 r23594 33 33 YNNYY Nebulous/nebclient ipp-2-8 -0 34 34 YNNYY Nebulous ipp-2-8 -0 35 YNNYY Nebulous-Server ipp-2-8 -0 35 36 YYYYY PS-IPP-Metadata-Config ipp-2-8 -0 36 37 YYYYY PS-IPP-Config ipp-2-8 -0 … … 68 69 YYYYY DataStore ipp-2-8 -0 69 70 71 YNNNN extsrc/gpcsw ipp-2-8 -0 72 70 73 # there are externally required C libraries and perl modules (see INSTALL) -
branches/cnb_branches/cnb_branch_20090301/psphot
- Property svn:mergeinfo changed
/trunk/psphot merged: 23442,23445,23486-23487,23492,23535
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.h
r23352 r23594 23 23 24 24 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 25 bool psphotInit ( );25 bool psphotInit (void); 26 26 bool psphotReadout (pmConfig *config, const pmFPAview *view); 27 27 bool psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, psArray *inSources); … … 35 35 36 36 // XXX test functions 37 psArray *psphotFakeSources ( );37 psArray *psphotFakeSources (void); 38 38 39 39 // psphotReadout functions … … 76 76 77 77 // thread-related: 78 bool psphotSetThreads ( );78 bool psphotSetThreads (void); 79 79 bool psphotChooseCellSizes (int *Cx, int *Cy, pmReadout *readout, int nThreads); 80 80 bool psphotCoordToCell (int *group, int *cell, float x, float y, int Cx, int Cy); … … 136 136 bool psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources); 137 137 bool psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources); 138 bool psphotFitInit ( );139 bool psphotFitSummary ( );138 bool psphotFitInit (int nThreads); 139 bool psphotFitSummary (void); 140 140 141 141 bool psphotMergeSources (psArray *oldSources, psArray *newSources); … … 230 230 psImage *pmPCMDataSaveImage (pmPCMData *pcm); 231 231 232 int psphotKapaOpen ( );233 bool psphotKapaClose ( );232 int psphotKapaOpen (void); 233 bool psphotKapaClose (void); 234 234 bool psphotImageBackgroundCellHistogram (psVector *values, float mean, float sigma, int ix, int iy); 235 235 bool psphotDiagnosticPlots (const pmConfig *config, const char *name, ...); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotCleanup.c
r21341 r23594 18 18 } 19 19 20 psExit psphotGetExitStatus ( ) {20 psExit psphotGetExitStatus (void) { 21 21 22 22 psErrorCode err = psErrorCodeLast (); 23 23 switch (err) { 24 24 case PS_ERR_NONE: 25 return PS_EXIT_SUCCESS;25 return PS_EXIT_SUCCESS; 26 26 case PSPHOT_ERR_SYS: 27 27 return PS_EXIT_SYS_ERROR; -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotDetect.h
r21392 r23594 19 19 bool psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile); 20 20 void psphotCleanup (pmConfig *config); 21 psExit psphotGetExitStatus ( );21 psExit psphotGetExitStatus (void); 22 22 23 23 #endif -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotFitSourcesLinear.c
r21519 r23594 63 63 pmSource *source = sources->data[i]; 64 64 65 // turn this bit off and turn it on again if we pass this test66 source->mode &= ~PM_SOURCE_MODE_LINEAR_FIT;65 // turn this bit off and turn it on again if we pass this test 66 source->mode &= ~PM_SOURCE_MODE_LINEAR_FIT; 67 67 68 68 // skip non-astronomical objects (very likely defects) … … 70 70 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 71 71 72 // do not include CRs in the full ensemble fit72 // do not include CRs in the full ensemble fit 73 73 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 74 74 … … 94 94 if (y > AnalysisRegion.y1) continue; 95 95 96 source->mode |= PM_SOURCE_MODE_LINEAR_FIT;96 source->mode |= PM_SOURCE_MODE_LINEAR_FIT; 97 97 psArrayAdd (fitSources, 100, source); 98 98 } 99 99 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), sources->n); 100 101 if (fitSources->n == 0) { 102 return true; 103 } 100 104 101 105 // vectors to store stats for each object … … 189 193 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "solve matrix: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); 190 194 191 // XXXX **** philosophical question: 195 // XXXX **** philosophical question: 192 196 // we measure bright objects in three passes: 1) linear fit; 2) non-linear fit; 3) linear fit: 193 // should retain the chisq and errors from the intermediate non-linear fit? 194 // the non-linear fit provides better values for the position errors, and for 197 // should retain the chisq and errors from the intermediate non-linear fit? 198 // the non-linear fit provides better values for the position errors, and for 195 199 // extended sources, the shape errors 196 200 … … 218 222 for (int i = 0; final && (i < fitSources->n); i++) { 219 223 pmSource *source = fitSources->data[i]; 220 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue;224 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue; 221 225 pmModel *model = pmSourceGetModel (NULL, source); 222 226 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMaskReadout.c
r23352 r23594 12 12 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat); 13 13 14 psImageMaskType maskBad = pmConfigMaskGet("BAD", config); // Mask value for bad pixels 14 psImageMaskType maskBad = pmConfigMaskGet("LOW", config); // Mask value for low pixels 15 if (!maskBad) { 16 // XXX: for backward compatability look up old name 17 maskBad = pmConfigMaskGet("BAD", config); 18 } 15 19 psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad); 16 20 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadout.c
r21366 r23594 2 2 3 3 // this should be called by every program that links against libpsphot 4 bool psphotInit ( ) {4 bool psphotInit (void) { 5 5 6 6 psphotErrorRegister(); // register our error codes/messages -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadoutFindPSF.c
r21366 r23594 11 11 if (!recipe) { 12 12 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE); 13 return false; 14 } 15 16 // set the photcode for this image 17 if (!psphotAddPhotcode(recipe, config, view, "PSPHOT.INPUT")) { 18 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 13 19 return false; 14 20 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadoutKnownSources.c
r21366 r23594 11 11 if (!recipe) { 12 12 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE); 13 return false; 14 } 15 16 // set the photcode for this image 17 if (!psphotAddPhotcode(recipe, config, view, "PSPHOT.INPUT")) { 18 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 13 19 return false; 14 20 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadoutMinimal.c
r21366 r23594 19 19 if (!recipe) { 20 20 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE); 21 return false; 22 } 23 24 // set the photcode for this image 25 if (!psphotAddPhotcode(recipe, config, view, "PSPHOT.INPUT")) { 26 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 21 27 return false; 22 28 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotStandAlone.h
r12805 r23594 17 17 bool psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile); 18 18 void psphotCleanup (pmConfig *config); 19 psExit psphotGetExitStatus ( );19 psExit psphotGetExitStatus (void); 20 20 21 21 #endif -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarp.h
r23352 r23594 72 72 } pswarpTransformTileArgs; 73 73 74 pswarpTransformTileArgs *pswarpTransformTileArgsAlloc( );74 pswarpTransformTileArgs *pswarpTransformTileArgsAlloc(void); 75 75 bool pswarpTransformTile (pswarpTransformTileArgs *args); 76 76 … … 87 87 bool pswarpMatchRange (int *minX, int *minY, int *maxX, int *maxY, pmReadout *dest, pmReadout *src); 88 88 89 pswarpMap *pswarpMapAlloc ( );89 pswarpMap *pswarpMapAlloc (void); 90 90 pswarpMapGrid *pswarpMapGridAlloc (int Nx, int Ny); 91 91 … … 111 111 * define threads for this program 112 112 */ 113 bool pswarpSetThreads ( );113 bool pswarpSetThreads (void); 114 114 115 115 /// Return software version -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpMapGrid.c
r21323 r23594 43 43 // measure the map for the center of each superpixel 44 44 for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) { 45 for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {46 pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j);47 }45 for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) { 46 pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j); 47 } 48 48 } 49 49 50 50 grid->nXpix = nXpix; 51 51 grid->nYpix = nYpix; … … 112 112 113 113 for (int i = 0; i < grid->nXpts - 1; i++) { 114 for (int j = 0; j < grid->nYpts - 1; j++) {115 116 // measure the output coordinates for the next grid position using the current grid map117 // compare with the coordinates measured using the next grid map118 pswarpMapApply (&xRaw, &yRaw, grid->maps[i][j], grid->maps[i][j]->xo + grid->nXpix, grid->maps[i][j]->yo);119 pswarpMapApply (&xRef, &yRef, grid->maps[i+1][j], grid->maps[i][j]->xo + grid->nXpix, grid->maps[i][j]->yo);120 121 double posError = hypot (xRaw-xRef, yRaw-yRef);122 maxError = PS_MAX (maxError, posError);123 }124 } 114 for (int j = 0; j < grid->nYpts - 1; j++) { 115 116 // measure the output coordinates for the next grid position using the current grid map 117 // compare with the coordinates measured using the next grid map 118 pswarpMapApply (&xRaw, &yRaw, grid->maps[i][j], grid->maps[i][j]->xo + grid->nXpix, grid->maps[i][j]->yo); 119 pswarpMapApply (&xRef, &yRef, grid->maps[i+1][j], grid->maps[i][j]->xo + grid->nXpix, grid->maps[i][j]->yo); 120 121 double posError = hypot (xRaw-xRef, yRaw-yRef); 122 maxError = PS_MAX (maxError, posError); 123 } 124 } 125 125 return maxError; 126 126 } … … 176 176 psPlaneTransformApply (FP, fpaDest->fromTPA, TP); 177 177 psPlaneTransformApply (V00, chipDest->fromFPA, FP); 178 178 179 179 /** V(1,0) position */ 180 180 offset->x = ix + 1; … … 186 186 psPlaneTransformApply (FP, fpaDest->fromTPA, TP); 187 187 psPlaneTransformApply (V10, chipDest->fromFPA, FP); 188 188 189 189 /** V(0,1) position */ 190 190 offset->x = ix; … … 204 204 map->Yy = V01->y - V00->y; 205 205 map->Yo = V00->y - map->Yx*ix - map->Yy*iy; 206 206 207 207 map->xo = ix; 208 208 map->yo = iy; … … 224 224 } 225 225 226 pswarpMap *pswarpMapAlloc () {226 pswarpMap *pswarpMapAlloc(void) { 227 227 228 228 pswarpMap *map = (pswarpMap *) psAlloc (sizeof(pswarpMap)); … … 238 238 239 239 for (int i = 0; i < grid->nXpts; i++) { 240 for (int j = 0; j < grid->nYpts; j++) {241 psFree (grid->maps[i][j]);242 }243 psFree (grid->maps[i]);240 for (int j = 0; j < grid->nYpts; j++) { 241 psFree (grid->maps[i][j]); 242 } 243 psFree (grid->maps[i]); 244 244 } 245 245 psFree (grid->maps); … … 256 256 grid->maps[i] = psAlloc (nYpts*sizeof(void *)); 257 257 for (int j = 0; j < nYpts; j++) { 258 grid->maps[i][j] = pswarpMapAlloc();258 grid->maps[i][j] = pswarpMapAlloc(); 259 259 } 260 260 } … … 264 264 grid->nXpix = 0; 265 265 grid->nYpix = 0; 266 266 267 267 return grid; 268 268 } -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpParseCamera.c
r23352 r23594 24 24 25 25 // look for the file on the RUN metadata 26 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return26 pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return 27 27 if (!status) { 28 28 psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule); -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpSetMaskBits.c
r21368 r23594 33 33 34 34 // mask for non-linear flat regions (default to DETECTOR if not defined) 35 psImageMaskType badMask = pmConfigMaskGet(" BAD.WARP", config);35 psImageMaskType badMask = pmConfigMaskGet("CONV.BAD", config); 36 36 if (!badMask) { 37 37 badMask = 0x01; 38 pmConfigMaskSet (config, " BAD.WARP", badMask);38 pmConfigMaskSet (config, "CONV.BAD", badMask); 39 39 } 40 40 maskOut |= badMask; 41 41 42 42 // mask for non-linear flat regions (default to DETECTOR if not defined) 43 psImageMaskType poorMask = pmConfigMaskGet(" POOR.WARP", config);43 psImageMaskType poorMask = pmConfigMaskGet("CONV.POOR", config); 44 44 if (!poorMask) { 45 45 poorMask = 0x02; 46 pmConfigMaskSet (config, " POOR.WARP", poorMask);46 pmConfigMaskSet (config, "CONV.POOR", poorMask); 47 47 } 48 48 maskOut |= poorMask; -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpSetThreads.c
r21323 r23594 23 23 } 24 24 25 bool pswarpSetThreads () {25 bool pswarpSetThreads(void) { 26 26 27 27 psThreadTask *task = NULL; -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpTransformReadout.c
r21529 r23594 37 37 // output mask bits 38 38 psImageMaskType maskIn = psMetadataLookupImageMask(&mdok, recipe, "MASK.INPUT"); 39 psImageMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 40 psImageMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 39 psImageMaskType maskPoor = pmConfigMaskGet("CONV.POOR", config); 40 if (!maskPoor) { 41 maskPoor = pmConfigMaskGet("POOR.WARP", config); 42 } 43 psImageMaskType maskBad = pmConfigMaskGet("CONV.BAD", config); 44 if (!maskBad) { 45 maskBad = pmConfigMaskGet("BAD.WARP", config); 46 } 41 47 psAssert(mdok, "MASK.INPUT was not defined"); 42 48 -
branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpTransformTile.c
r21368 r23594 24 24 } 25 25 26 pswarpTransformTileArgs *pswarpTransformTileArgsAlloc( )26 pswarpTransformTileArgs *pswarpTransformTileArgsAlloc(void) 27 27 { 28 28 pswarpTransformTileArgs *args = psAlloc(sizeof(pswarpTransformTileArgs));
Note:
See TracChangeset
for help on using the changeset viewer.
