Changeset 25870
- Timestamp:
- Oct 18, 2009, 10:23:28 AM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 deleted
- 163 edited
- 24 copied
-
. (modified) (1 prop)
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (11 diffs)
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm (modified) (2 diffs)
-
archive/ducttape (modified) (1 prop)
-
catalyst (modified) (1 prop)
-
catalyst/2007.0-specs (modified) (1 prop)
-
catalyst/2008.0-specs (modified) (1 prop)
-
catalyst/2008.0-specs/hardened (modified) (1 prop)
-
dbconfig/add.md (modified) (2 diffs)
-
dbconfig/cam.md (modified) (2 diffs)
-
dbconfig/changes.1.1.56 (copied) (copied from trunk/dbconfig/changes.1.1.56 )
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/chip.md (modified) (2 diffs)
-
dbconfig/config.md (modified) (1 diff)
-
dbconfig/dbversion.md (copied) (copied from trunk/dbconfig/dbversion.md )
-
dbconfig/diff.md (modified) (2 diffs)
-
dbconfig/dist.md (modified) (2 diffs)
-
dbconfig/fake.md (modified) (2 diffs)
-
dbconfig/flatcorr.md (modified) (1 diff)
-
dbconfig/ipp.m4 (modified) (1 diff)
-
dbconfig/magic.md (modified) (2 diffs)
-
dbconfig/pstamp.md (modified) (1 diff)
-
dbconfig/stack.md (modified) (2 diffs)
-
dbconfig/warp.md (modified) (2 diffs)
-
extperl (modified) (1 prop)
-
extperl/ExtUtils-MakeMaker-6.31.tar.gz (deleted)
-
extperl/ExtUtils-MakeMaker-6.54.tar.gz (copied) (copied from trunk/extperl/ExtUtils-MakeMaker-6.54.tar.gz )
-
hardware (modified) (1 prop)
-
ippMonitor/Makefile.in (modified) (1 diff)
-
ippMonitor/def/flatcorrCamera.d (copied) (copied from trunk/ippMonitor/def/flatcorrCamera.d )
-
ippMonitor/def/flatcorrChip.d (copied) (copied from trunk/ippMonitor/def/flatcorrChip.d )
-
ippMonitor/raw/ipp.detrend.dat (modified) (1 diff)
-
ippMonitor/raw/ipp.php (modified) (1 diff)
-
ippScripts/Build.PL (modified) (1 diff)
-
ippScripts/scripts/addstar_run.pl (modified) (10 diffs)
-
ippScripts/scripts/camera_exp.pl (modified) (2 diffs)
-
ippScripts/scripts/detrend_process_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/dist_make_fileset.pl (modified) (5 diffs)
-
ippScripts/scripts/flatcorr_proc.pl (modified) (1 diff)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (21 diffs)
-
ippScripts/scripts/magic_definerun.pl (deleted)
-
ippScripts/scripts/magic_destreak_cleanup.pl (copied) (copied from trunk/ippScripts/scripts/magic_destreak_cleanup.pl )
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (1 prop)
-
ippScripts/scripts/stack_skycell.pl (modified) (1 diff)
-
ippTasks/addstar.pro (modified) (2 diffs)
-
ippTasks/destreak.pro (modified) (7 diffs)
-
ippTasks/flatcorr.pro (modified) (4 diffs)
-
ippTasks/ipphosts.mhpcc.config (modified) (3 diffs)
-
ippTasks/pstamp.pro (modified) (1 diff)
-
ippTasks/rcserver.pro (modified) (2 diffs)
-
ippTasks/simtest.basic.auto (modified) (4 diffs)
-
ippTasks/simtest.stack.auto (modified) (1 diff)
-
ippTasks/survey.pro (modified) (1 diff)
-
ippTests/tap (modified) (1 prop)
-
ippTools/configure.ac (modified) (3 diffs)
-
ippTools/share/Makefile.am (modified) (8 diffs)
-
ippTools/share/addtool_donecleanup.sql (copied) (copied from trunk/ippTools/share/addtool_donecleanup.sql )
-
ippTools/share/addtool_find_cam_id.sql (copied) (copied from trunk/ippTools/share/addtool_find_cam_id.sql )
-
ippTools/share/addtool_find_pendingexp.sql (modified) (3 diffs)
-
ippTools/share/addtool_find_processedexp.sql (copied) (copied from trunk/ippTools/share/addtool_find_processedexp.sql )
-
ippTools/share/addtool_pendingcleanupexp.sql (copied) (copied from trunk/ippTools/share/addtool_pendingcleanupexp.sql )
-
ippTools/share/addtool_pendingcleanuprun.sql (copied) (copied from trunk/ippTools/share/addtool_pendingcleanuprun.sql )
-
ippTools/share/addtool_queue_cam_id.sql (modified) (1 diff)
-
ippTools/share/camtool_find_processedexp.sql (modified) (1 diff)
-
ippTools/share/camtool_queue_chip_id.sql (modified) (2 diffs)
-
ippTools/share/chiptool_completely_processed_exp.sql (modified) (2 diffs)
-
ippTools/share/chiptool_processedimfile.sql (modified) (1 diff)
-
ippTools/share/chiptool_run.sql (modified) (1 diff)
-
ippTools/share/chiptool_runstate.sql (copied) (copied from trunk/ippTools/share/chiptool_runstate.sql )
-
ippTools/share/difftool_change_run_state.sql (copied) (copied from trunk/ippTools/share/difftool_change_run_state.sql )
-
ippTools/share/difftool_change_skyfile_data_state.sql (copied) (copied from trunk/ippTools/share/difftool_change_skyfile_data_state.sql )
-
ippTools/share/difftool_pendingcleanuprun.sql (modified) (1 diff)
-
ippTools/share/difftool_skyfile.sql (modified) (1 diff)
-
ippTools/share/disttool_definebyquery_camera.sql (modified) (2 diffs)
-
ippTools/share/disttool_definebyquery_chip.sql (modified) (2 diffs)
-
ippTools/share/disttool_definebyquery_diff.sql (modified) (2 diffs)
-
ippTools/share/disttool_definebyquery_fake.sql (modified) (2 diffs)
-
ippTools/share/disttool_definebyquery_raw.sql (modified) (1 diff)
-
ippTools/share/disttool_definebyquery_stack.sql (modified) (2 diffs)
-
ippTools/share/disttool_definebyquery_warp.sql (modified) (2 diffs)
-
ippTools/share/disttool_defineinterest.sql (modified) (1 diff)
-
ippTools/share/disttool_pending_camera.sql (modified) (2 diffs)
-
ippTools/share/disttool_pending_chip.sql (modified) (2 diffs)
-
ippTools/share/disttool_pending_diff.sql (modified) (2 diffs)
-
ippTools/share/disttool_pending_fake.sql (modified) (2 diffs)
-
ippTools/share/disttool_pending_raw.sql (modified) (4 diffs)
-
ippTools/share/disttool_pending_stack.sql (modified) (2 diffs)
-
ippTools/share/disttool_pending_warp.sql (modified) (2 diffs)
-
ippTools/share/disttool_pendingfileset.sql (modified) (1 diff)
-
ippTools/share/faketool_completely_processed_exp.sql (modified) (2 diffs)
-
ippTools/share/faketool_queue_cam_id.sql (modified) (2 diffs)
-
ippTools/share/flatcorr_camerarundone.sql (copied) (copied from trunk/ippTools/share/flatcorr_camerarundone.sql )
-
ippTools/share/flatcorr_chiprundone.sql (modified) (2 diffs)
-
ippTools/share/flatcorr_pendingprocess.sql (modified) (1 diff)
-
ippTools/share/magicdstool_tocleanup.sql (copied) (copied from trunk/ippTools/share/magicdstool_tocleanup.sql )
-
ippTools/share/pstamptool_pendingdependent.sql (copied) (copied from trunk/ippTools/share/pstamptool_pendingdependent.sql )
-
ippTools/share/pstamptool_pendingjob.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (29 diffs)
-
ippTools/share/pxadmin_drop_tables.sql (modified) (3 diffs)
-
ippTools/share/pxadmin_update_version.sql (copied) (copied from trunk/ippTools/share/pxadmin_update_version.sql )
-
ippTools/share/warptool_runstate.sql (copied) (copied from trunk/ippTools/share/warptool_runstate.sql )
-
ippTools/share/warptool_warped.sql (modified) (1 diff)
-
ippTools/src/Makefile.am (modified) (2 diffs)
-
ippTools/src/addtool.c (modified) (23 diffs)
-
ippTools/src/addtoolConfig.c (modified) (5 diffs)
-
ippTools/src/camtool.c (modified) (8 diffs)
-
ippTools/src/camtoolConfig.c (modified) (2 diffs)
-
ippTools/src/chiptool.c (modified) (16 diffs)
-
ippTools/src/chiptool.h (modified) (1 diff)
-
ippTools/src/chiptoolConfig.c (modified) (7 diffs)
-
ippTools/src/difftool.c (modified) (26 diffs)
-
ippTools/src/difftool.h (modified) (1 diff)
-
ippTools/src/difftoolConfig.c (modified) (6 diffs)
-
ippTools/src/disttool.c (modified) (24 diffs)
-
ippTools/src/disttool.h (modified) (1 diff)
-
ippTools/src/disttoolConfig.c (modified) (8 diffs)
-
ippTools/src/faketool.c (modified) (7 diffs)
-
ippTools/src/faketoolConfig.c (modified) (2 diffs)
-
ippTools/src/flatcorr.c (modified) (18 diffs)
-
ippTools/src/flatcorr.h (modified) (2 diffs)
-
ippTools/src/flatcorrConfig.c (modified) (4 diffs)
-
ippTools/src/magicdstool.c (modified) (13 diffs)
-
ippTools/src/magicdstool.h (modified) (2 diffs)
-
ippTools/src/magicdstoolConfig.c (modified) (5 diffs)
-
ippTools/src/magictool.c (modified) (4 diffs)
-
ippTools/src/pstamptool.c (modified) (5 diffs)
-
ippTools/src/pstamptool.h (modified) (1 diff)
-
ippTools/src/pstamptoolConfig.c (modified) (3 diffs)
-
ippTools/src/pxadd.c (modified) (4 diffs)
-
ippTools/src/pxadd.h (modified) (1 diff)
-
ippTools/src/pxadmin.c (modified) (5 diffs)
-
ippTools/src/pxcam.c (modified) (3 diffs)
-
ippTools/src/pxcam.h (modified) (2 diffs)
-
ippTools/src/pxchip.c (modified) (6 diffs)
-
ippTools/src/pxchip.h (modified) (2 diffs)
-
ippTools/src/pxfake.c (modified) (3 diffs)
-
ippTools/src/pxfake.h (modified) (2 diffs)
-
ippTools/src/pxmagic.c (modified) (2 diffs)
-
ippTools/src/pxmagic.h (modified) (1 diff)
-
ippTools/src/pxspace.c (copied) (copied from trunk/ippTools/src/pxspace.c )
-
ippTools/src/pxspace.h (copied) (copied from trunk/ippTools/src/pxspace.h )
-
ippTools/src/pxtools.c (modified) (1 diff)
-
ippTools/src/pxtools.h (modified) (3 diffs)
-
ippTools/src/pxwarp.c (modified) (2 diffs)
-
ippTools/src/pxwarp.h (modified) (1 diff)
-
ippTools/src/regtool.c (modified) (4 diffs)
-
ippTools/src/regtoolConfig.c (modified) (1 diff)
-
ippTools/src/stacktool.c (modified) (12 diffs)
-
ippTools/src/stacktoolConfig.c (modified) (4 diffs)
-
ippTools/src/warptool.c (modified) (15 diffs)
-
ippTools/src/warptool.h (modified) (1 diff)
-
ippTools/src/warptoolConfig.c (modified) (7 diffs)
-
ippconfig/gpc1/ppImage.config (modified) (6 diffs)
-
ippconfig/megacam/ppImage.config (modified) (1 diff)
-
ippconfig/recipes/addstar.config (modified) (1 diff)
-
ippconfig/recipes/filerules-split.mdc (modified) (1 diff)
-
ippconfig/recipes/ppImage.config (modified) (7 diffs)
-
ippconfig/recipes/psphot.config (modified) (1 diff)
-
ippconfig/sdssmosaic/addstar.config (modified) (1 diff)
-
ippconfig/simtest/ppStack.config (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (2 diffs)
-
ppImage/src/ppImageSetMaskBits.c (modified) (1 diff)
-
ppMerge/src/ppMergeLoop.c (modified) (11 diffs)
-
ppStack/src/ppStackFinish.c (modified) (1 diff)
-
ppSub/src/ppSub.c (modified) (1 diff)
-
ppSub/src/ppSubData.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileFitsIO.c (modified) (2 diffs)
-
psModules/src/camera/pmReadoutFake.c (modified) (1 prop)
-
psModules/src/config/pmConfigMask.c (modified) (1 diff)
-
psModules/src/objects/pmPSF_IO.c (modified) (3 diffs)
-
psModules/src/objects/pmPSFtryModel.c (modified) (4 diffs)
-
psconfig/pscheckperl (modified) (7 diffs)
-
psconfig/tagsets/ipp-2.9.perl (modified) (1 diff)
-
psphot/doc/efficiency.txt (modified) (1 prop)
-
psphot/src/psphot.h (modified) (3 diffs)
-
psphot/src/psphotFake.c (modified) (1 prop)
-
psphot/src/psphotRoughClass.c (modified) (6 diffs)
-
psphot/src/psphotSourceSize.c (modified) (15 diffs)
-
psphot/src/psphotSourceStats.c (modified) (6 diffs)
-
psphot/src/psphotVisual.c (modified) (21 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (11 diffs)
-
pstamp/src/ppstampMakeStamp.c (modified) (1 diff)
-
pstamp/test/byskycell.txt (modified) (1 diff)
-
pswarp/src/pswarpLoop.c (modified) (1 diff)
-
tools/definetargets (copied) (copied from trunk/tools/definetargets )
-
tools/gpc1_find_images.pl (copied) (copied from trunk/tools/gpc1_find_images.pl )
-
tools/ipp_apply_burntool.pl (modified) (2 diffs)
-
tools/neb-ds9.pl (copied) (copied from trunk/tools/neb-ds9.pl )
-
tools/warp_outputs.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
-
branches/eam_branches/20090820/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r25766 r25870 108 108 } elsif ($req_type eq "bycoord") { 109 109 110 # run 111 # regtool -dbname $image_db -processedimfile -time_begin $mjd_min -time_end = $mjd_max -filter $filter 112 # 113 my $results = lookup_bycoord($ipprc, $image_db, $x, $y, $dateobs_begin, $dateobs_end, $filter, $verbose); 114 115 # now take the results and lookup byexp 116 # XXX: This needs work. What stops results from returning multiple images???? 117 # We should loop over the set of images returned building up the full results array 118 $req_type = "byexp"; 119 $id = $results->{exp_name}; 110 if ($img_type eq "stack") { 111 print STDERR "Error bycoord lookup not implemented for stage stack yet\n"; 112 return undef; 113 } 120 114 } elsif ($req_type eq "byskycell") { 121 115 if (($img_type eq "raw") or ($img_type eq "chip")) { … … 129 123 } 130 124 131 my $results = lookup($ipprc, $image_db, $req_type, $img_type, $id, $tess_id, $component, $need_magic, $ dateobs_begin, $dateobs_end, $filter, $label, $verbose);125 my $results = lookup($ipprc, $image_db, $req_type, $img_type, $id, $tess_id, $component, $need_magic, $x, $y, $dateobs_begin, $dateobs_end, $filter, $label, $verbose); 132 126 133 127 return $results; 134 128 } 135 129 136 sub lookup { 130 sub lookup 131 { 137 132 my $ipprc = shift; 138 133 my $image_db = shift; … … 143 138 my $component= shift; 144 139 my $need_magic = shift; 140 my $x = shift; 141 my $y = shift; 145 142 my $dateobs_begin = shift; 146 143 my $dateobs_end = shift; … … 175 172 176 173 my $magic_arg = $need_magic ? " -destreaked" : ""; 174 my $component_args; 177 175 if ($img_type eq "raw") { 178 176 $class_id = $component; 179 177 $command = "$regtool -processedimfile -dbname $image_db"; 178 # XXX: for now restrict lookups to type object 179 # are stamps of detrend exposures interesting? 180 $command .= " -exp_type object"; 180 181 $id_opt = "-exp_id"; 181 $com mand .= " -class_id $class_id" if $component;182 $component_args = " -class_id $class_id" if $component; 182 183 $want_astrom = 1; 183 184 $set_class_id = 1; … … 185 186 $class_id = $component; 186 187 $command = "$chiptool -processedimfile -dbname $image_db"; 187 $com mand .= " -class_id $class_id" if $class_id;188 $component_args = " -class_id $class_id" if $class_id; 188 189 $id_opt = "-chip_id"; 189 190 $image_name = "PPIMAGE.CHIP"; … … 196 197 $skycell_id = $component; 197 198 $command = "$warptool -warped -dbname $image_db"; 198 $com mand .= " -skycell_id $skycell_id" if $skycell_id;199 $component_args = " -skycell_id $skycell_id" if $skycell_id; 199 200 $id_opt = "-warp_id"; 200 201 $image_name = "PSWARP.OUTPUT"; … … 205 206 $skycell_id = $component; 206 207 $command = "$difftool -diffskyfile -dbname $image_db"; 207 $com mand .= " -skycell_id $skycell_id" if $skycell_id;208 $component_args = " -skycell_id $skycell_id" if $skycell_id; 208 209 $id_opt = "-diff_id"; 209 210 $image_name = "PPSUB.OUTPUT"; … … 212 213 $base_name = "path_base"; 213 214 } elsif ($img_type eq "stack") { 215 $skycell_id = $component; 214 216 $command = "$stacktool -sumskyfile -dbname $image_db"; 215 217 $id_opt = "-stack_id"; 218 $component_args = " -skycell_id $skycell_id" if $skycell_id; 216 219 217 220 $image_name = "PPSTACK.OUTPUT"; … … 225 228 if ($req_type eq "byid") { 226 229 $command .= " $id_opt $id"; 230 $command .= $component_args if $component_args; 227 231 } elsif ($req_type eq "byexp") { 228 232 $command .= " -exp_name $id"; 233 $command .= $component_args if $component_args; 229 234 } elsif ($req_type eq "byskycell") { 235 die "tess_id and component are required for byskycell" if !$tess_id or ! $skycell_id; 230 236 $command .= " -tess_id $tess_id -skycell_id $skycell_id"; 237 } elsif ($req_type eq "bycoord") { 238 $command .= " -radius 3.0 -ra $x -decl $y"; 231 239 } else { 232 240 die "Unknown req_type supplied: $req_type"; … … 289 297 290 298 # if uri is nil this will get overridded below 291 # ( this isfor raw stage)299 # (we do this here for raw stage) 292 300 $out->{image} = $image->{uri}; 293 301 if ($set_class_id) { … … 295 303 $out->{component} = $class_id; 296 304 } 305 my $stage_id; 306 if ($img_type eq "raw") { 307 $stage_id = $image->{exp_id}; 308 } elsif ($img_type eq "chip") { 309 $stage_id = $image->{chip}; 310 } elsif ($img_type eq "warp") { 311 $stage_id = $image->{warp_id}; 312 } elsif ($img_type eq "diff") { 313 $stage_id = $image->{diff_id}; 314 } elsif ($img_type eq "stack") { 315 $stage_id = $image->{stack_id}; 316 } 317 $image->{stage_id} = $stage_id; 318 $image->{stage} = $img_type; 319 $image->{image_db} = $image_db; 297 320 298 321 # find the mask and weight images 299 322 if ($base) { 300 $out->{image} = $ipprc->filename($image_name, $base, $class_id) if $image_name;323 $out->{image} = $ipprc->filename($image_name, $base, $class_id) if $image_name; 301 324 $out->{mask} = $ipprc->filename($mask_name, $base, $class_id) if $mask_name; 302 325 $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name; -
branches/eam_branches/20090820/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm
r25126 r25870 23 23 $PSTAMP_SELECT_WEIGHT 24 24 $PSTAMP_SELECT_INVERSE 25 $PSTAMP_WAIT_FOR_UPDATE 25 26 $PSTAMP_SUCCESS 26 27 $PSTAMP_SYSTEM_ERROR … … 49 50 50 51 our $PSTAMP_SELECT_INVERSE = 1024; 52 our $PSTAMP_WAIT_FOR_UPDATE = 2048; 51 53 52 54 # job and result codes -
branches/eam_branches/20090820/archive/ducttape
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/catalyst
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/catalyst/2007.0-specs
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/catalyst/2008.0-specs
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/catalyst/2008.0-specs/hardened
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/dbconfig/add.md
r25766 r25870 1 # XXX rename these 'addstarRun', etc... (add_id -> addstar_id) 1 2 addRun METADATA 2 3 add_id S64 0 # Primary Key AUTO_INCREMENT 3 4 cam_id S64 0 # Key INDEX(add_id,cam_id) fkey(cam_id) ref camRun(cam_id) 4 state STR 64 # key5 state STR 64 # Key 5 6 workdir STR 255 6 7 workdir_state STR 64 8 reduction STR 64 7 9 label STR 64 10 data_group STR 64 # Key 8 11 dvodb STR 255 9 magicked S64 0 12 note STR 255 13 image_only BOOL f 10 14 END 11 15 … … 13 17 add_id S64 0 # Primary Key AUTO_INCREMENT 14 18 dtime_addstar F32 0.0 15 16 n_stars S32 017 18 19 path_base STR 255 19 20 fault S16 0 # Key NOT NULL -
branches/eam_branches/20090820/dbconfig/cam.md
r24681 r25870 6 6 workdir_state STR 64 # key 7 7 label STR 64 # key 8 data_group STR 64 # key 9 dist_group STR 64 # key 8 10 reduction STR 64 9 11 expgroup STR 64 # key … … 12 14 end_stage STR 64 # Key 13 15 magicked S64 0 16 note STR 255 14 17 END 15 18 -
branches/eam_branches/20090820/dbconfig/changes.txt
r25766 r25870 1300 1300 1301 1301 ALTER TABLE pstampJob ADD COLUMN options BIGINT; 1302 1303 ALTER TABLE addRun ADD COLUMN reduction VARCHAR(64) AFTER workdir_state; 1304 ALTER TABLE addRun DROP COLUMN magicked; 1305 ALTER TABLE addRun ADD COLUMN image_only tinyint after dvodb; 1306 ALTER TABLE addProcessedExp DROP COLUMN n_stars; 1307 1308 CREATE TABLE flatcorrAddstarLink ( 1309 corr_id BIGINT, 1310 cam_id BIGINT, 1311 add_id BIGINT, 1312 include TINYINT, 1313 PRIMARY KEY(corr_id, cam_id, add_id), 1314 FOREIGN KEY (corr_id) REFERENCES flatcorrRun(corr_id), 1315 FOREIGN KEY (cam_id) REFERENCES camRun(cam_id), 1316 FOREIGN KEY (add_id) REFERENCES addRun(add_id) 1317 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1318 1319 ALTER TABLE pstampJob ADD COLUMN dep_id BIGINT; 1320 CREATE TABLE pstampDependent ( 1321 dep_id BIGINT AUTO_INCREMENT, 1322 state VARCHAR(64), 1323 stage VARCHAR(64), 1324 stage_id BIGINT, 1325 imagedb VARCHAR(64), 1326 rlabel VARCHAR(64), 1327 no_magic TINYINT, 1328 PRIMARY KEY(dep_id) 1329 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1330 1331 1332 ALTER TABLE chipRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1333 ALTER TABLE chipRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1334 ALTER TABLE chipRun ADD COLUMN note VARCHAR(255) AFTER magicked; 1335 ALTER TABLE chipRun ADD KEY(data_group); 1336 ALTER TABLE chipRun ADD KEY(dist_group); 1337 1338 UPDATE chipRun SET data_group = label; 1339 UPDATE chipRun SET dist_group = label; 1340 1341 ALTER TABLE camRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1342 ALTER TABLE camRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1343 ALTER TABLE camRun ADD COLUMN note VARCHAR(255) AFTER magicked; 1344 ALTER TABLE camRun ADD KEY(data_group); 1345 ALTER TABLE camRun ADD KEY(dist_group); 1346 1347 UPDATE camRun SET data_group = label; 1348 UPDATE camRun SET dist_group = label; 1349 1350 ALTER TABLE addRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1351 ALTER TABLE addRun ADD COLUMN note VARCHAR(255) AFTER dvodb; 1352 ALTER TABLE addRun ADD KEY(data_group); 1353 1354 UPDATE addRun SET data_group = label; 1355 1356 ALTER TABLE fakeRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1357 ALTER TABLE fakeRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1358 ALTER TABLE fakeRun ADD COLUMN note VARCHAR(255) AFTER epoch; 1359 ALTER TABLE fakeRun ADD KEY(data_group); 1360 ALTER TABLE fakeRun ADD KEY(dist_group); 1361 1362 UPDATE fakeRun SET data_group = label; 1363 UPDATE fakeRun SET dist_group = label; 1364 1365 ALTER TABLE warpRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1366 ALTER TABLE warpRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1367 ALTER TABLE warpRun ADD COLUMN note VARCHAR(255) AFTER magicked; 1368 ALTER TABLE warpRun ADD KEY(data_group); 1369 ALTER TABLE warpRun ADD KEY(dist_group); 1370 1371 UPDATE warpRun SET data_group = label; 1372 UPDATE warpRun SET dist_group = label; 1373 1374 ALTER TABLE stackRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1375 ALTER TABLE stackRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1376 ALTER TABLE stackRun ADD COLUMN note VARCHAR(255) AFTER filter; 1377 ALTER TABLE stackRun ADD KEY(data_group); 1378 ALTER TABLE stackRun ADD KEY(dist_group); 1379 1380 UPDATE stackRun SET data_group = label; 1381 UPDATE stackRun SET dist_group = label; 1382 1383 ALTER TABLE diffRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1384 ALTER TABLE diffRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group; 1385 ALTER TABLE diffRun ADD COLUMN note VARCHAR(255) AFTER magicked; 1386 ALTER TABLE diffRun ADD KEY(data_group); 1387 ALTER TABLE diffRun ADD KEY(dist_group); 1388 1389 UPDATE diffRun SET data_group = label; 1390 UPDATE diffRun SET dist_group = label; 1391 1392 ALTER TABLE magicRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1393 ALTER TABLE magicRun ADD COLUMN note VARCHAR(255) AFTER fault; 1394 ALTER TABLE magicRun ADD KEY(data_group); 1395 1396 UPDATE magicRun SET data_group = label; 1397 1398 ALTER TABLE magicDSRun ADD COLUMN data_group VARCHAR(64) AFTER label; 1399 ALTER TABLE magicDSRun ADD COLUMN fault SMALLINT after remove; 1400 ALTER TABLE magicDSRun ADD COLUMN note VARCHAR(255) AFTER fault; 1401 ALTER TABLE magicDSRun ADD KEY(fault); 1402 ALTER TABLE magicDSRun ADD KEY(data_group); 1403 1404 UPDATE magicDSRun SET data_group = label; 1405 UPDATE magicDSRun SET fault = 0; 1406 1407 ALTER TABLE distRun ADD COLUMN note VARCHAR(255) after fault; 1408 1409 ALTER TABLE distTarget CHANGE COLUMN label dist_group VARCHAR(64); 1410 1411 ALTER TABLE rcDestination ADD CONSTRAINT UNIQUE(name); 1412 1413 CREATE TABLE dbversion ( 1414 schema_version VARCHAR(64), 1415 updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP 1416 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1417 1418 INSERT INTO dbversion VALUES('1.1.56', CURRENT_TIMESTAMP); 1419 1420 1421 -- Vesion 1.1.57 1422 1423 -- add changes for 1.1.57 here. Then uncomment the following before commiting 1424 1425 -- UPDATE dbversion set schema_version = '1.1.57', updated= CURRENT_TIMESTAMP(); -
branches/eam_branches/20090820/dbconfig/chip.md
r24552 r25870 6 6 workdir_state STR 64 # Key 7 7 label STR 64 # Key 8 data_group STR 64 # Key 9 dist_group STR 64 # Key 8 10 reduction STR 64 # Reduction class 9 11 expgroup STR 64 # Key … … 12 14 end_stage STR 64 # Key 13 15 magicked S64 0 16 note STR 255 14 17 END 15 18 -
branches/eam_branches/20090820/dbconfig/config.md
r25766 r25870 2 2 pkg_name STR ippdb 3 3 pkg_namespace STR ippdb 4 pkg_version STR 1.1.5 54 pkg_version STR 1.1.56 5 5 END -
branches/eam_branches/20090820/dbconfig/diff.md
r24552 r25870 6 6 workdir STR 255 7 7 label STR 64 # Key 8 data_group STR 64 9 dist_group STR 64 8 10 reduction STR 64 # Reduction class 9 11 dvodb STR 255 … … 13 15 exposure BOOL f 14 16 magicked S64 0 17 note STR 255 15 18 END 16 19 -
branches/eam_branches/20090820/dbconfig/dist.md
r25766 r25870 1 1 distTarget METADATA 2 2 target_id S64 0 # Primary Key 3 labelSTR 643 dist_group STR 64 4 4 filter STR 64 5 5 stage STR 64 … … 22 22 time_stamp UTC 0001-01-01T00:00:00Z 23 23 fault S16 0 24 note STR 255 24 25 END 25 26 -
branches/eam_branches/20090820/dbconfig/fake.md
r19930 r25870 5 5 workdir STR 255 6 6 label STR 64 # Key 7 data_group STR 64 # Key 8 dist_group STR 64 # Key 7 9 reduction STR 64 # Reduction class 8 10 expgroup STR 64 # Key … … 11 13 end_stage STR 64 # Key 12 14 epoch UTC 0001-01-01T00:00:00Z 15 note STR 255 13 16 END 14 17 -
branches/eam_branches/20090820/dbconfig/flatcorr.md
r20397 r25870 33 33 END 34 34 35 # table of exposures sent to addstar 36 flatcorrAddstarLink METADATA 37 corr_id S64 0 # Primary Key fkey(corr_id) ref flatcorrRun(corr_id) 38 cam_id S64 0 # Primary Key fkey(chip_id) ref chipRun(chip_id) 39 add_id S64 0 # Primary Key fkey(chip_id) ref chipRun(chip_id) 40 include BOOL t 41 END 42 -
branches/eam_branches/20090820/dbconfig/ipp.m4
r25766 r25870 9 9 dnl include(telescope.md) 10 10 dnl include(skycell.md) 11 include(dbversion.md) 11 12 include(summitcopy.md) 12 13 include(new.md) -
branches/eam_branches/20090820/dbconfig/magic.md
r25014 r25870 11 11 workdir_state STR 255 # Key 12 12 label STR 64 # key 13 data_group STR 64 13 14 dvodb STR 255 14 15 registered TAI NULL 15 16 fault S16 0 # Key 17 note STR 255 16 18 END 17 19 … … 53 55 cam_id S64 0 54 56 label STR 64 # key 57 data_group STR 64 # key 55 58 outroot STR 255 56 59 recoveryroot STR 255 57 60 re_place BOOL f 58 61 remove BOOL f 62 fault S16 0 # Key 63 note STR 255 59 64 END 60 65 -
branches/eam_branches/20090820/dbconfig/pstamp.md
r25766 r25870 40 40 outputBase STR 255 41 41 options S64 64 42 dep_id S64 0 42 43 END 44 45 pstampDependent METADATA 46 dep_id S64 0 # Primary Key AUTO_INCREMENT 47 state STR 64 48 stage STR 64 49 stage_id S64 0 50 imagedb STR 64 51 rlabel STR 64 52 no_magic BOOL f 53 END -
branches/eam_branches/20090820/dbconfig/stack.md
r23688 r25870 6 6 workdir STR 255 7 7 label STR 64 # Key 8 data_group STR 64 # Key 9 dist_group STR 64 # Key 8 10 reduction STR 64 # Reduction class 9 11 dvodb STR 255 … … 12 14 tess_id STR 64 # Key 13 15 filter STR 64 16 note STR 255 14 17 END 15 18 -
branches/eam_branches/20090820/dbconfig/warp.md
r24552 r25870 17 17 workdir_state STR 64 # Key 18 18 label STR 64 # key 19 data_group STR 64 20 dist_group STR 64 19 21 dvodb STR 255 20 22 tess_id STR 64 … … 23 25 registered TAI NULL 24 26 magicked S64 0 27 note STR 255 25 28 END 26 29 -
branches/eam_branches/20090820/extperl
- Property svn:ignore
-
old new 1 Abstract-Meta-Class-0.13 1 2 Apache-DBI-1.06 2 3 Apache-Test-1.29 … … 13 14 DBD-mysql-4.006 14 15 DBI-1.601 16 DBIx-Connection-0.13 15 17 DB_File-1.814 16 18 Data-Validate-Domain-0.05 … … 60 62 Params-Validate-0.87 61 63 Params-Validate-0.91 64 Params-Validate-0.92 62 65 Parse-RecDescent-1.94 63 66 SOAP-Lite-0.69 64 67 SQL-Interp-1.06 68 Simple-SAX-Serializer-0.05 65 69 Statistics-Descriptive-2.6 66 70 Storable-2.15 … … 68 72 Template-Toolkit-2.16 69 73 Test-Cmd-1.05 74 Test-DBUnit-0.20 75 Test-Distribution-2.00 70 76 Test-Exception-0.24 71 77 Test-Simple-0.74
-
- Property svn:ignore
-
branches/eam_branches/20090820/hardware
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/ippMonitor/Makefile.in
r24868 r25870 151 151 $(DESTWWW)/calRun.php \ 152 152 $(DESTWWW)/flatcorrRun.php \ 153 $(DESTWWW)/flatcorr Exp.php154 153 $(DESTWWW)/flatcorrChip.php \ 154 $(DESTWWW)/flatcorrCamera.php 155 155 156 156 PICTURES = \ -
branches/eam_branches/20090820/ippMonitor/raw/ipp.detrend.dat
r24868 r25870 53 53 menutop | menutop | plain | Flat Correction | 54 54 menulink | menuselect | link | Flat Corr Runs | flatcorrRun.php 55 menulink | menuselect | link | Flat Corr Exp | flatcorrExp.php 55 menulink | menuselect | link | Flat Corr Chip Runs | flatcorrChip.php 56 menulink | menuselect | link | Flat Corr Camera Runs | flatcorrCamera.php -
branches/eam_branches/20090820/ippMonitor/raw/ipp.php
r24759 r25870 285 285 $file = fopen ($source, "r"); 286 286 287 global $DBHOST; 288 $HOST = $_SERVER['SERVER_NAME']; 289 echo "<p style=\"font-size:50%\">host: $HOST, db: $DBHOST</p>\n"; 287 290 echo "<table class=page cellspacing=10px><tr><td valign=top>\n"; 288 291 echo "<table class=menu cellspacing=0px>\n"; -
branches/eam_branches/20090820/ippScripts/Build.PL
r25766 r25870 59 59 scripts/magic_destreak.pl 60 60 scripts/magic_destreak_revert.pl 61 scripts/magic_destreak_cleanup.pl 61 62 scripts/ippdb.pl 62 63 scripts/ipp_cleanup.pl -
branches/eam_branches/20090820/ippScripts/scripts/addstar_run.pl
r25766 r25870 28 28 # Look for programs we need 29 29 my $missing_tools; 30 #my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);31 30 my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1); 32 #my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);33 31 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 34 #my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);35 #my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);36 32 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 37 33 if ($missing_tools) { … … 40 36 } 41 37 42 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,43 $no_op, $redirect, $save_temps , $run_state);38 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update, 39 $no_op, $redirect, $save_temps); 44 40 GetOptions( 45 41 'exp_tag=s' => \$exp_tag, # Exposure identifier 46 42 'add_id=s' => \$add_id, # Camtool identifier 47 'recipe=s' => \$recipe, # Recipe to use48 43 'camera|c=s' => \$camera, # Camera 49 44 'dbname|d=s' => \$dbname, # Database name … … 52 47 'reduction=s' => \$reduction, # Reduction class 53 48 'dvodb|w=s' => \$dvodb, # output DVO database 54 ' run-state=s' => \$run_state, # 'new' or 'update'49 'image-only' => \$image_only, # Print to stdout 55 50 'verbose' => \$verbose, # Print to stdout 56 51 'no-update' => \$no_update, # Update the database? … … 74 69 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 75 70 76 if (not defined $run_state) { $run_state = 'new'; }77 if ($run_state eq 'update') {78 $logDest .= '.update';79 }80 81 71 if ($redirect) { 82 72 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $add_id, $PS_EXIT_SYS_ERROR ); … … 89 79 $reduction = 'DEFAULT' unless defined $reduction; 90 80 81 # XXX This is now not used: do we still need it? 91 82 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use 92 83 &my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar; 93 84 94 #my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use95 #&my_die("Unrecognised PSASTRO recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;96 97 85 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 98 99 my $cmdflags;100 101 # Get list of component files102 my $files; # Array of component files103 {104 my $command = "$addtool -pendingexp -add_id $add_id"; # Command to run105 $command .= " -dbname $dbname" if defined $dbname;106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =107 run(command => $command, verbose => $verbose);108 unless ($success) {109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);110 &my_die("Unable to perform addtool: $error_code", $add_id, $error_code);111 }112 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or113 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_PROG_ERROR);114 115 # extract the metadata for the files into a hash list116 $files = parse_md_list($metadata) or117 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);118 }119 120 my $chipObjectsExist = 0;121 86 122 87 # Output products … … 126 91 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $camroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 127 92 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 128 129 if ($run_state eq 'update') {130 $traceDest .= '.update';131 }132 93 133 94 # convert supplied DVO database name to UNIX filename … … 141 102 142 103 unless ($no_op) { 143 if (defined $dvodbReal and ($run_state eq 'new')) { 144 ## XXX the camera analysis can either save the full set of 145 ## detections, or just the image metadata, in the dvodb 104 if (defined $dvodbReal) { 105 106 ## addstar can either save the full set of detections, or just 107 ## the image metadata, in the dvodb. this is set in the 108 ## database table addRun 146 109 147 ## get the addstar recipe for this camera and CAMERA reduction 148 my $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -"; 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => $verbose); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to perform ppConfigDump: $error_code", $add_id, $PS_EXIT_SYS_ERROR); 154 } 155 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 156 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_SYS_ERROR); 157 158 ## allow the dvodb to save only images, or the full detection set 159 my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY'); 160 161 # XXX this construct requires the user to have a valid .ptolemyrc 162 # XXX which in turn points at ippconfig/dvo.site 110 # addstar requires the user to have a valid .ptolemyrc which 111 # in turn points at ippconfig/dvo.site 112 113 # get the names for the camera and the real input file 114 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 115 my $realFile = $ipprc->file_resolve($fpaObjects); 116 163 117 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 164 # XXX this needs to be converted to addstar_client... 165 166 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 167 $command = "$addstar -D CAMERA $camdir -update"; 168 $command .= " -image" if $imagesOnly; 118 my $command = "$addstar -update"; # XXX optionally set -update? 119 $command .= " -D CAMERA $camdir"; 169 120 $command .= " -D CATDIR $dvodbReal"; 170 171 my $realFile = $ipprc->file_resolve($fpaObjects);172 121 $command .= " $realFile"; 122 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference 123 $command .= " -image" if $image_only; 173 124 174 125 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 175 126 176 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 177 128 run(command => $command, verbose => $verbose); 178 129 unless ($success) { … … 184 135 } 185 136 186 187 137 # This needs to be updated when addtool is written. BROKEN 188 138 my $fpaCommand = "$addtool -add_id $add_id"; 189 if ($run_state eq 'new') { 190 $fpaCommand .= " -addprocessedexp"; 191 $fpaCommand .= " -path_base $outroot"; 192 $fpaCommand .= " $cmdflags"; 193 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 194 } else { 195 $fpaCommand .= " -updaterun -state full"; 196 } 139 $fpaCommand .= " -addprocessedexp"; 140 $fpaCommand .= " -path_base $outroot"; 141 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 197 142 $fpaCommand .= " -dbname $dbname" if defined $dbname; 198 143 … … 223 168 # This needs to be updated when addtool is written. BROKEN 224 169 my $command = "$addtool -add_id $add_id"; 225 if ($run_state eq 'new') { 226 $command .= " -addprocessedexp"; 227 $command .= " -uri UNKNOWN"; 228 $command .= " -fault $exit_code"; 229 $command .= " -path_base $outroot"; 230 $command .= " -path_base $outroot" if defined $outroot; 231 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 232 } else { 233 $command .= " -updateprocessedexp"; 234 $command .= " -fault $exit_code"; 235 } 170 $command .= " -addprocessedexp"; 171 $command .= " -fault $exit_code"; 172 $command .= " -path_base $outroot" if defined $outroot; 173 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 236 174 $command .= " -dbname $dbname" if defined $dbname; 237 175 system ($command); … … 239 177 exit $exit_code; 240 178 } 241 242 179 243 180 END { -
branches/eam_branches/20090820/ippScripts/scripts/camera_exp.pl
r25766 r25870 39 39 } 40 40 41 my ( $exp_tag, $cam_id, $camera, $outroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,41 my ( $exp_tag, $cam_id, $camera, $outroot, $dbname, $reduction, $dvodb, $verbose, $no_update, 42 42 $no_op, $redirect, $save_temps, $run_state); 43 43 GetOptions( 44 44 'exp_tag=s' => \$exp_tag, # Exposure identifier 45 45 'cam_id=s' => \$cam_id, # Camtool identifier 46 'recipe=s' => \$recipe, # Recipe to use47 46 'camera|c=s' => \$camera, # Camera 48 47 'dbname|d=s' => \$dbname, # Database name … … 355 354 # $fpaCommand .= " -dtime_addstar $dtime_addstar"; 356 355 } else { 357 $fpaCommand .= " -updaterun -s tate full";356 $fpaCommand .= " -updaterun -set_state full"; 358 357 } 359 358 $fpaCommand .= " -dbname $dbname" if defined $dbname; -
branches/eam_branches/20090820/ippScripts/scripts/detrend_process_imfile.pl
r24764 r25870 94 94 'DOMEFLAT' => 'PPIMAGE.OUTPUT.DETREND', 95 95 'SKYFLAT' => 'PPIMAGE.OUTPUT.DETREND', 96 'FRINGE' => undef,96 'FRINGE' => 'PPIMAGE.OUTPUT.DETREND', 97 97 }; 98 98 -
branches/eam_branches/20090820/ippScripts/scripts/dist_make_fileset.pl
r25766 r25870 40 40 # Parse the command-line arguments 41 41 my ($dist_id, $dist_dir, $target_id, $stage, $stage_id, $dest_id, $product_name, $ds_dbhost, $ds_dbname); 42 my ($label, $ filter);42 my ($label, $dist_group, $filter); 43 43 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 44 44 … … 51 51 'dest_id=s' => \$dest_id, # id for the product 52 52 'product_name=s' => \$product_name, # location of the data store directory for this product 53 'label=s' => \$label, 53 'label=s' => \$label, 54 'dist_group=s' => \$dist_group, 54 55 'filter=s' => \$filter, 55 56 'ds_dbhost=s' => \$ds_dbhost, # database host for the datastore database … … 63 64 64 65 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 65 pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id -- label--filter --dest_id --ds_dbhost --ds_dbname",66 pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id --dist_group --filter --dest_id --ds_dbhost --ds_dbname", 66 67 -exitval => 3) unless 67 68 defined $dist_id and … … 70 71 defined $stage and 71 72 defined $stage_id and 72 defined $ labeland73 defined $dist_group and 73 74 defined $filter and 74 75 defined $dest_id and … … 161 162 162 163 $command .= " --ps0 $target_id --ps1 $stage --ps2 $stage_id --ps3 $prod_col_3"; 163 $command .= " --ps4 $ label--ps5 $filter";164 $command .= " --ps4 $dist_group --ps5 $filter"; 164 165 165 166 $command .= " --dbname $ds_dbname --dbhost $ds_dbhost"; -
branches/eam_branches/20090820/ippScripts/scripts/flatcorr_proc.pl
r23688 r25870 104 104 my ($DECs, $DECe) = split (",", $coords[1]); 105 105 106 # Run addstar -resort to ensure the db is indexed 107 { 108 my $command = "$addstar -resort"; 106 # Run addstar -resort to ensure the db is indexed 107 # XXX addstar should be able to recognize and skip indexed tables 108 { 109 my $command = "$addstar -resort"; 109 110 $command .= " -D CATDIR $dvodb"; 110 111 $command .= " -region $RAs $RAe $DECs $DECe"; -
branches/eam_branches/20090820/ippScripts/scripts/ipp_cleanup.pl
r25766 r25870 91 91 92 92 # if there are no chipProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new' 93 # XXX Why? This could just mean there's nothing to cleanup, or that we're trying to rerun an errored run. 93 94 if (@$stdout_buf == 0) { 94 my $command = "$chiptool -chip_id $stage_id -updaterun -set_state new";95 my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state"; 95 96 $command .= " -dbname $dbname" if defined $dbname; 96 97 … … 123 124 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); 124 125 125 # if (!$config_file or ! -e $config_file) {126 126 unless ($ipprc->file_exists($config_file)) { 127 127 print STDERR "skipping cleanup for chipRun $stage_id $class_id " … … 187 187 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 188 188 } 189 190 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 191 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 192 $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned"; 193 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 194 run(command => $command, verbose => $verbose); 195 unless ($success) { 196 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 197 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code); 198 } 199 189 200 } else { 190 201 … … 199 210 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 200 211 } 212 213 # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again. 214 $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state"; 215 $command .= " -dbname $dbname" if defined $dbname; 216 217 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 218 run(command => $command, verbose => $verbose); 219 unless ($success) { 220 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 221 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 222 } 223 201 224 } 202 225 } … … 283 306 &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code); 284 307 } 308 309 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 310 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 311 $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned"; 312 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 313 run(command => $command, verbose => $verbose); 314 unless ($success) { 315 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 316 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code); 317 } 318 285 319 } else { 286 320 # since 'camera' has only a single imfile, we can just update the run … … 296 330 exit $PS_EXIT_UNKNOWN_ERROR; 297 331 } 332 333 298 334 exit 0; 299 335 } … … 314 350 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 315 351 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 352 } 353 354 if (@$stdout_buf == 0) { 355 # No skycells were found for some reason. 356 # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself." 357 my $command = "$warptool -updaterun -warp_id $stage_id -set_state $error_state"; 358 $command .= " -dbname $dbname" if defined $dbname; 359 360 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 361 run(command => $command, verbose => $verbose); 362 unless ($success) { 363 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 364 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 365 } 366 367 exit(0); 316 368 } 317 369 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or … … 389 441 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 390 442 } 443 444 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 445 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 446 $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned"; 447 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 448 run(command => $command, verbose => $verbose); 449 unless ($success) { 450 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 451 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code); 452 } 453 391 454 } else { 392 455 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state"; … … 399 462 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 400 463 } 401 exit $PS_EXIT_UNKNOWN_ERROR; 464 465 # exit $PS_EXIT_UNKNOWN_ERROR; 402 466 } 403 467 } … … 407 471 ### added for cleanup, based on warp stage entry 408 472 if ($stage eq 'stack') { 409 410 473 die "--stage_id required for stage stack\n" if !$stage_id; 411 412 474 # this stage uses 'stacktool' 413 475 my $stacktool = can_run('stacktool') or die "Can't find stacktool"; … … 422 484 &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code); 423 485 } 486 487 if (@$stdout_buf == 0) { 488 # No skycells were found for some reason. 489 # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself." 490 my $command = "$stacktool -updaterun -stack_id $stage_id -set_state $error_state"; 491 $command .= " -dbname $dbname" if defined $dbname; 492 493 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 494 run(command => $command, verbose => $verbose); 495 unless ($success) { 496 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 497 &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code); 498 } 499 500 exit(0); 501 } 502 424 503 my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or 425 504 &my_die("Unable to parse metadata config doc", "stack", $stage_id, $PS_EXIT_PROG_ERROR); … … 434 513 435 514 my $status = 1; 436 if ($mode eq "goto_cleaned") { 437 my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id); 438 439 unless ($ipprc->file_exists($config_file)) { 440 print STDERR "skipping cleanup for stackRun $stage_id $skycell_id" . 441 " because config file is missing\n"; 442 $status = 0; 443 } 444 } 445 elsif ($mode eq "goto_scrubbed") { 446 my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id); 447 448 if ($ipprc->file_exists($config_file)) { 449 print STDERR "skipping scrubbed for stackRun $stage_id $skycell_id" . 450 " because config file is present\n"; 451 $status = 0; 452 } 453 } 515 if ((!exists($skyfile->{path_base}))|| 516 (!defined($path_base))) { 517 $status = 0; 518 } 519 if ($status) { 520 if ($mode eq "goto_cleaned") { 521 my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id); 522 523 unless ($ipprc->file_exists($config_file)) { 524 print STDERR "skipping cleanup for stackRun $stage_id $skycell_id" . 525 " because config file is missing\n"; 526 $status = 0; 527 } 528 } 529 elsif ($mode eq "goto_scrubbed") { 530 my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id); 531 532 if ($ipprc->file_exists($config_file)) { 533 print STDERR "skipping scrubbed for stackRun $stage_id $skycell_id" . 534 " because config file is present\n"; 535 $status = 0; 536 } 537 } 538 } 539 454 540 if ($status) { 455 541 my @files = (); … … 475 561 my $command = "$stacktool -stack_id $stage_id"; 476 562 if ($mode eq "goto_purged") { 477 $command .= " -updaterun -s tate purged";563 $command .= " -updaterun -set_state purged"; 478 564 } 479 565 elsif ($mode eq "goto_cleaned") { 480 $command .= " -updaterun -s tate cleaned";566 $command .= " -updaterun -set_state cleaned"; 481 567 } 482 568 elsif ($mode eq "goto_scrubbed") { 483 $command .= " -updaterun -s tate scrubbed";569 $command .= " -updaterun -set_state scrubbed"; 484 570 } 485 571 $command .= " -dbname $dbname" if defined $dbname; … … 491 577 &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code); 492 578 } 579 580 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 581 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 582 $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned"; 583 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 584 run(command => $command, verbose => $verbose); 585 unless ($success) { 586 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 587 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code); 588 } 589 493 590 } else { 494 my $command = "$stacktool -updaterun -stack_id $stage_id -s tate $error_state";591 my $command = "$stacktool -updaterun -stack_id $stage_id -set_state $error_state"; 495 592 $command .= " -dbname $dbname" if defined $dbname; 496 593 … … 501 598 &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code); 502 599 } 503 exit $PS_EXIT_UNKNOWN_ERROR;600 # exit $PS_EXIT_UNKNOWN_ERROR; 504 601 } 505 602 } … … 523 620 &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code); 524 621 } 622 623 if (@$stdout_buf == 0) { 624 # No skycells were found for some reason. 625 # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself." 626 my $command = "$difftool -updaterun -diff_id $stage_id -set_state $error_state"; 627 $command .= " -dbname $dbname" if defined $dbname; 628 629 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 630 run(command => $command, verbose => $verbose); 631 unless ($success) { 632 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 633 &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code); 634 } 635 636 exit(0); 637 } 638 525 639 my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or 526 640 &my_die("Unable to parse metadata config doc", "diff", $stage_id, $PS_EXIT_PROG_ERROR); … … 535 649 536 650 my $status = 1; 537 if ($mode eq "goto_cleaned") { 538 my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id); 539 540 unless ($ipprc->file_exists($config_file)) { 541 print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" . 542 " because config file ($config_file) is missing\n"; 543 $status = 0; 544 } 545 } 546 elsif ($mode eq "goto_scrubbed") { 547 my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id); 548 549 if ($ipprc->file_exists($config_file)) { 550 print STDERR "skipping scrubbed for diffRun $stage_id $skycell_id" . 551 " because config file ($config_file) is present\n"; 552 $status = 0; 651 if ((!exists($skyfile->{path_base}))|| 652 (!defined($path_base))) { 653 $status = 0; 654 } 655 if ($status) { 656 657 if ($mode eq "goto_cleaned") { 658 my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id); 659 660 unless ($ipprc->file_exists($config_file)) { 661 print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" . 662 " because config file ($config_file) is missing\n"; 663 $status = 0; 664 } 665 } 666 elsif ($mode eq "goto_scrubbed") { 667 my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id); 668 669 if ($ipprc->file_exists($config_file)) { 670 print STDERR "skipping scrubbed for diffRun $stage_id $skycell_id" . 671 " because config file ($config_file) is present\n"; 672 $status = 0; 673 } 553 674 } 554 675 } … … 588 709 # print STDERR "MY STATUS: $status\n"; 589 710 if ($status) { 590 my $command = "$difftool -diff_id $stage_id ";591 592 if ($mode eq "goto_purged") { 593 $command .= " - updaterun -state purged";711 my $command = "$difftool -diff_id $stage_id -skycell_id $skycell_id"; 712 713 if ($mode eq "goto_purged") { 714 $command .= " -topurgedskyfile"; 594 715 } 595 716 elsif ($mode eq "goto_cleaned") { 596 $command .= " - updaterun -state cleaned";717 $command .= " -tocleanedskyfile"; 597 718 } 598 719 elsif ($mode eq "goto_scrubbed") { 599 $command .= " - updaterun -state scrubbed";720 $command .= " -toscrubbedskyfile"; 600 721 } 601 722 … … 608 729 &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code); 609 730 } 731 732 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 733 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 734 $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned"; 735 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 736 run(command => $command, verbose => $verbose); 737 unless ($success) { 738 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 739 &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code); 740 } 741 610 742 } else { 611 my $command = "$difftool -updaterun -diff_id $stage_id -s tate $error_state";743 my $command = "$difftool -updaterun -diff_id $stage_id -set_state $error_state"; 612 744 613 745 $command .= " -dbname $dbname" if defined $dbname; … … 619 751 &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code); 620 752 } 621 exit $PS_EXIT_UNKNOWN_ERROR;753 # exit $PS_EXIT_UNKNOWN_ERROR; 622 754 } 623 755 } … … 646 778 # if there are no fakeProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new' 647 779 if (@$stdout_buf == 0) { 648 my $command = "$faketool -fake_id $stage_id -updaterun -set_state new";780 my $command = "$faketool -fake_id $stage_id -updaterun -set_state $error_state"; 649 781 $command .= " -dbname $dbname" if defined $dbname; 650 782 -
branches/eam_branches/20090820/ippScripts/scripts/magic_destreak_revert.pl
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/ippScripts/scripts/stack_skycell.pl
r25766 r25870 304 304 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 305 305 } else { 306 $mode = "-updaterun -s tate full";306 $mode = "-updaterun -set_state full"; 307 307 } 308 308 $command .= " $mode -stack_id $stack_id"; -
branches/eam_branches/20090820/ippTasks/addstar.pro
r25766 r25870 121 121 book getword addPendingExp $pageName exp_tag -var EXP_TAG 122 122 book getword addPendingExp $pageName add_id -var ADD_ID 123 book getword addPendingExp $pageName cam _id -var CAM_ID123 book getword addPendingExp $pageName camroot -var CAMROOT 124 124 book getword addPendingExp $pageName workdir -var WORKDIR_TEMPLATE 125 book getword addPendingExp $pageName reduction -var REDUCTION 125 126 book getword addPendingExp $pageName dvodb -var DVODB 127 book getword addPendingExp $pageName image_only -var IMAGE_ONLY 126 128 book getword addPendingExp $pageName dbname -var DBNAME 127 book getword addPendingExp $pageName reduction -var REDUCTION128 book getword addPendingExp $pageName state -var RUN_STATE129 129 130 130 # specify choice of remote host based on camera and chip (class_id) … … 144 144 ## generate outroot specific to this exposure (& chip) 145 145 sprintf outroot "%s/%s/%s.add.%s" $WORKDIR $EXP_TAG $EXP_TAG $ADD_ID 146 sprintf camroot "%s/%s/%s.cm.%s" $WORKDIR $EXP_TAG $EXP_TAG $CAM_ID147 146 148 147 stdout $LOGDIR/addstar.exp.log 149 148 stderr $LOGDIR/addstar.exp.log 150 149 151 $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA -- outroot $outroot --camroot $camroot --redirect-output --run-state $RUN_STATE150 $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA --dvodb $DVODB --camroot $CAMROOT --outroot $outroot --redirect-output 152 151 if ("$REDUCTION" != "NULL") 153 152 $run = $run --reduction $REDUCTION 154 153 end 155 if ("$DVODB" != "NULL") 156 $run = $run --dvodb $DVODB 157 end 154 if ("$IMAGE_ONLY" == "T") 155 $run = $run --image-only 156 end 157 158 158 add_standard_args run 159 159 -
branches/eam_branches/20090820/ippTasks/destreak.pro
r25766 r25870 10 10 book init magicToDS 11 11 book init magicDSToRevert 12 book init magicDSToCleanup 12 13 13 14 ### indexes into Database lists … … 16 17 $magicDSToRevert_DB = 0 17 18 $magicDSCompletedRevert_DB = 0 19 $magicDSToCleanup_DB = 0 18 20 19 21 #list of stages … … 32 34 book listbook magicToDS 33 35 book listbook magicDSToRevert 36 book init magicDSToCleanup 34 37 end 35 38 … … 38 41 book init magicToDS 39 42 book init magicDSToRevert 43 book init magicDSToCleanup 40 44 end 41 45 … … 71 75 end 72 76 77 macro destreak.cleanup.on 78 task destreak.cleanup.load 79 active true 80 end 81 task destreak.cleanup.run 82 active true 83 end 84 end 85 73 86 ### Turn tasks off 74 87 macro destreak.off … … 92 105 end 93 106 task destreak.completed.revert 107 active false 108 end 109 end 110 macro destreak.cleanup.off 111 task destreak.cleanup.load 112 active false 113 end 114 task destreak.cleanup.run 94 115 active false 95 116 end … … 489 510 end 490 511 512 task destreak.cleanup.load 513 host local 514 515 periods -poll $LOADPOLL 516 periods -exec $LOADEXEC 517 periods -timeout 20 518 npending 1 519 active false 520 521 stdout NULL 522 stderr $LOGSUBDIR/destreak.cleanup.load.log 523 524 task.exec 525 $run = magicdstool -tocleanup 526 if ($DB:n == 0) 527 option DEFAULT 528 else 529 530 # save the DB name for the exit tasks 531 option $DB:$magicDSToCleanup_DB 532 $run = $run -dbname $DB:$magicDSToCleanup_DB 533 534 # only bump database number after we have gone through all of the stages 535 $magicDSToCleanup_DB ++ 536 if ($magicDSToCleanup_DB >= $DB:n) set magicDSToCleanup_DB = 0 537 end 538 add_poll_args run 539 add_poll_labels run 540 command $run 541 end 542 543 # success 544 task.exit 0 545 # convert 'stdout' to book format 546 ipptool2book stdout magicDSToCleanup -key magic_ds_id -uniq -setword dbname $options:0 -setword pantaskState INIT 547 if ($VERBOSE > 2) 548 book listbook magicDSToCleanup 549 end 550 551 # delete existing entries in the appropriate pantaskStates 552 process_cleanup magicDSToCleanup 553 end 554 555 # locked list 556 task.exit default 557 showcommand failure 558 end 559 560 task.exit crash 561 showcommand crash 562 end 563 564 # operation times out? 565 task.exit timeout 566 showcommand timeout 567 end 568 end 569 570 task destreak.cleanup.run 571 periods -poll $RUNPOLL 572 periods -exec $RUNEXEC 573 periods -timeout 60 574 active false 575 576 task.exec 577 stdout $LOGSUBDIR/destreak.cleanup.run.log 578 stderr $LOGSUBDIR/destreak.cleanup.run.log 579 580 book npages magicDSToCleanup -var N 581 if ($N == 0) break 582 if ($NETWORK == 0) break 583 584 # look for new images (pantaskState == INIT) 585 book getpage magicDSToCleanup 0 -var pageName -key pantaskState INIT 586 if ("$pageName" == "NULL") break 587 588 book setword magicDSToCleanup $pageName pantaskState RUN 589 book getword magicDSToCleanup $pageName magic_ds_id -var MAGIC_DS_ID 590 book getword magicDSToCleanup $pageName camera -var CAMERA 591 book getword magicDSToCleanup $pageName outroot -var OUTROOT 592 book getword magicDSToCleanup $pageName dbname -var DBNAME 593 594 sprintf logfile "%s/mds.%s.cleanup.log" $OUTROOT $MAGIC_DS_ID 595 596 host anyhost 597 598 $run = magic_destreak_cleanup.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --logfile $logfile 599 600 add_standard_args run 601 602 # save the pageName for future reference below 603 options $pageName 604 605 # create the command line 606 if ($VERBOSE > 1) 607 echo command $run 608 end 609 command $run 610 end 611 612 # default exit status 613 task.exit 0 614 process_exit magicDSToCleanup $options:0 $JOB_STATUS 615 end 616 617 # locked list 618 task.exit default 619 showcommand failure 620 process_exit magicDSToCleanup $options:0 $JOB_STATUS 621 end 622 623 task.exit crash 624 showcommand crash 625 book setword magicDSToCleanup $options:0 pantaskState CRASH 626 end 627 628 # operation timed out? 629 task.exit timeout 630 showcommand timeout 631 book setword magicDSToCleanup $options:0 pantaskState TIMEOUT 632 end 633 end 634 -
branches/eam_branches/20090820/ippTasks/flatcorr.pro
r24139 r25870 2 2 ## this file contains the tasks for running the flatcorr stage 3 3 ## these tasks use the book 'flatcorrBook' 4 5 # test for required global variables6 check.globals7 8 book init flatcorrBook9 10 macro flatcorr.reset11 book init flatcorrBook12 end13 14 macro flatcorr.status15 book listbook flatcorrBook16 end17 18 macro flatcorr.on19 task flatcorr.addcamera20 active true21 end22 task flatcorr.load23 active true24 end25 task flatcorr.run26 active true27 end28 end29 30 macro flatcorr.off31 task flatcorr.addcamera32 active false33 end34 task flatcorr.load35 active false36 end37 task flatcorr.run38 active false39 end40 end41 42 # these variables will cycle through the known ippdb database names43 $flatcorr_addcamera_DB = 044 $flatcorr_pendingprocess_DB = 045 4 46 5 # a flat-field correction run is initiated (manually) with a command like: … … 55 14 # as the chip analysis progresses, we need to occasionally migrate the 56 15 # completed chips to the camera stage by calling: 57 # flatcorr -addcamera 58 59 # we wait for the completed chip and camera analysis and search for 16 # flatcorr -advancecamera 17 18 # as the camera analysis progresses, we need to occasionally migrate the 19 # completed exposures to the addstar stage by calling: 20 # flatcorr -advanceaddstar 21 22 # we wait for the completed addstar jobs and search for 60 23 # completed processing analysis with: 61 24 # flatcorr -pendingprocess … … 67 30 # flatcorr -addprocess -fault N 68 31 32 # test for required global variables 33 check.globals 34 35 book init flatcorrBook 36 37 macro flatcorr.reset 38 book init flatcorrBook 39 end 40 41 macro flatcorr.status 42 book listbook flatcorrBook 43 end 44 45 macro flatcorr.on 46 task flatcorr.advancecamera 47 active true 48 end 49 task flatcorr.advanceaddstar 50 active true 51 end 52 task flatcorr.load 53 active true 54 end 55 task flatcorr.run 56 active true 57 end 58 end 59 60 macro flatcorr.off 61 task flatcorr.advancecamera 62 active false 63 end 64 task flatcorr.advanceaddstar 65 active false 66 end 67 task flatcorr.load 68 active false 69 end 70 task flatcorr.run 71 active false 72 end 73 end 74 75 # these variables will cycle through the known ippdb database names 76 $flatcorr_advancecamera_DB = 0 77 $flatcorr_advanceaddstar_DB = 0 78 $flatcorr_pendingprocess_DB = 0 79 69 80 # migrate complete flatcorr chips to the camera stage analysis 70 task flatcorr.ad dcamera81 task flatcorr.advancecamera 71 82 host local 72 83 … … 80 91 # define the command (does not depend on previous queries) 81 92 if ($DB:n == 0) 82 command flatcorr -ad dcamera93 command flatcorr -advancecamera 83 94 else 84 95 # save the DB name for the exit tasks 85 96 # note that this DB name refers to the ippdb, not the dvodb 86 option $DB:$flatcorr_addcamera_DB 87 command flatcorr -addcamera -dbname $DB:$flatcorr_addcamera_DB 88 $flatcorr_addcamera_DB ++ 89 if ($flatcorr_addcamera_DB >= $DB:n) set flatcorr_addcamera_DB = 0 97 option $DB:$flatcorr_advancecamera_DB 98 command flatcorr -advancecamera -dbname $DB:$flatcorr_advancecamera_DB 99 $flatcorr_advancecamera_DB ++ 100 if ($flatcorr_advancecamera_DB >= $DB:n) set flatcorr_advancecamera_DB = 0 101 end 102 end 103 104 # silently drop stdout 105 stdout NULL 106 stderr $LOGDIR/flatcorr.log 107 108 # success (no action required) 109 task.exit $EXIT_SUCCESS 110 end 111 112 # locked list 113 task.exit default 114 showcommand failure 115 end 116 117 task.exit crash 118 showcommand crash 119 end 120 121 # operation times out? 122 task.exit timeout 123 showcommand timeout 124 end 125 end 126 127 # migrate complete flatcorr exposures to the addstar process 128 task flatcorr.advanceaddstar 129 host local 130 131 # check the list of pending flatcorr runs 132 periods -poll 5 133 periods -exec 30 134 periods -timeout 60 135 npending 1 136 137 task.exec 138 # define the command (does not depend on previous queries) 139 if ($DB:n == 0) 140 command flatcorr -advanceaddstar 141 else 142 # save the DB name for the exit tasks 143 # note that this DB name refers to the ippdb, not the dvodb 144 option $DB:$flatcorr_advanceaddstar_DB 145 command flatcorr -advanceaddstar -dbname $DB:$flatcorr_advanceaddstar_DB 146 $flatcorr_advanceaddstar_DB ++ 147 if ($flatcorr_advanceaddstar_DB >= $DB:n) set flatcorr_advanceaddstar_DB = 0 90 148 end 91 149 end -
branches/eam_branches/20090820/ippTasks/ipphosts.mhpcc.config
r25766 r25870 12 12 sky06 STR ipp012 13 13 sky07 STR ipp013 14 sky08 STR ipp014 14 # sky08 STR ipp014 15 sky08 STR ipp047 15 16 sky09 STR ipp015 16 17 sky10 STR ipp016 … … 55 56 camera STR GPC1 56 57 57 XY01 STR ipp014 58 XY02 STR ipp014 58 # XY01 STR ipp014 59 # XY02 STR ipp014 60 XY01 STR ipp047 61 XY02 STR ipp047 59 62 XY03 STR ipp038 60 63 XY04 STR ipp038 … … 134 137 camera STR gpc1 135 138 136 ota01 STR ipp014 137 ota02 STR ipp014 139 # ota01 STR ipp014 140 # ota02 STR ipp014 141 ota01 STR ipp047 142 ota02 STR ipp047 138 143 ota03 STR ipp038 139 144 ota04 STR ipp038 -
branches/eam_branches/20090820/ippTasks/pstamp.pro
r25766 r25870 111 111 112 112 task.exec 113 stdout $LOGSUBDIR/pstamp.request.find.log113 stdout NULL 114 114 stderr $LOGSUBDIR/pstamp.request.find.log 115 115 if ($DB:n == 0) -
branches/eam_branches/20090820/ippTasks/rcserver.pro
r25766 r25870 129 129 book getword rcPendingFS $pageName stage -var STAGE 130 130 book getword rcPendingFS $pageName stage_id -var STAGE_ID 131 book getword rcPendingFS $pageName label -var LABEL131 book getword rcPendingFS $pageName dist_group -var DIST_GROUP 132 132 book getword rcPendingFS $pageName filter -var FILTER 133 133 book getword rcPendingFS $pageName dist_dir -var DIST_DIR … … 149 149 book setword rcPendingFS $pageName pantaskState RUN 150 150 151 $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID -- label $LABEL--filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR151 $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID --dist_group $DIST_GROUP --filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR 152 152 153 153 add_standard_args run -
branches/eam_branches/20090820/ippTasks/simtest.basic.auto
r24174 r25870 47 47 name STR OBJECT-i 48 48 check STR "detselect -dbname @DBNAME@ -search -inst @CAMERA@ -filter i -det_type FLAT" 49 launch STR "chiptool -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter i -label wait -set_label proc "49 launch STR "chiptool -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter i -label wait -set_label proc -set_data_group simtest_i -set_dist_group simtest" 50 50 block STR NONE 51 51 END … … 54 54 name STR OBJECT-r 55 55 check STR "detselect -dbname @DBNAME@ -search -inst @CAMERA@ -filter r -det_type FLAT" 56 launch STR "chiptool -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter r -label wait -set_label proc "56 launch STR "chiptool -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter r -label wait -set_label proc -set_data_group simtest_r -set_dist_group simtest" 57 57 block STR NONE 58 58 END … … 61 61 automate METADATA 62 62 name STR STACK 63 regular STR "stacktool -definebyquery - all -label proc -workdir file://@CWD@/stack -min_new 4 -min_frac 2 -select_good_frac_min 0.2 -dbname @DBNAME@"63 regular STR "stacktool -definebyquery -set_label proc -set_data_group simtest_r -set_dist_group simtest -set_workdir file://@CWD@/stack -min_new 4 -min_frac 2 -select_good_frac_min 0.2 -dbname @DBNAME@" 64 64 END 65 65 … … 67 67 automate METADATA 68 68 name STR DIFF 69 regular STR "difftool -definewarpstack - label proc -workdir file://@CWD@/diff -good_frac 0.2 -dbname @DBNAME@"69 regular STR "difftool -definewarpstack -set_label proc -set_workdir file://@CWD@/diff -good_frac 0.2 -dbname @DBNAME@" 70 70 END 71 71 -
branches/eam_branches/20090820/ippTasks/simtest.stack.auto
r24098 r25870 61 61 automate METADATA 62 62 name STR STACK 63 regular STR "stacktool -definebyquery - all -label proc -workdir file://@CWD@/stack -min_new 4 -min_frac 2 -select_good_frac_min 0.2 -dbname @DBNAME@"63 regular STR "stacktool -definebyquery -label proc -workdir file://@CWD@/stack -min_new 4 -min_frac 2 -select_good_frac_min 0.2 -dbname @DBNAME@" 64 64 END 65 65 -
branches/eam_branches/20090820/ippTasks/survey.pro
r24989 r25870 4 4 check.globals 5 5 6 book create SURVEY_DIFF 7 book create SURVEY_MAGIC 6 book getbook SURVEY_DIFF -var isBook 7 if ("$isBook" == "NULL") 8 book create SURVEY_DIFF 9 end 10 book getbook SURVEY_MAGIC -var isBook 11 if ("$isBook" == "NULL") 12 book create SURVEY_MAGIC 13 end 8 14 9 15 $SURVEY_DIFF_DB = 0 -
branches/eam_branches/20090820/ippTests/tap
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/ippTools/configure.ac
r25766 r25870 1 1 AC_PREREQ(2.61) 2 2 3 AC_INIT([ipptools], [1.1. 37], [ipp-support@ifa.hawaii.edu])3 AC_INIT([ipptools], [1.1.56], [ipp-support@ifa.hawaii.edu]) 4 4 AC_CONFIG_SRCDIR([autogen.sh]) 5 5 … … 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.5 5])20 PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.56]) 21 21 22 22 PXTOOLS_CFLAGS="${PSLIB_CFLAGS=} ${PSMODULES_CFLAGS=} ${IPPDB_CFLAGS=}" … … 58 58 CFLAGS="${CFLAGS=} -Wall -Werror" 59 59 60 IPPDB_VERSION=`$PKG_CONFIG --modversion ippdb` 61 AC_DEFINE_UNQUOTED(IPPDB_VERSION, $IPPDB_VERSION, [Version of ippdb]) 62 60 63 AC_CONFIG_FILES([ 61 64 Makefile -
branches/eam_branches/20090820/ippTools/share/Makefile.am
r25766 r25870 4 4 5 5 dist_pkgdata_DATA = \ 6 addtool_donecleanup.sql \ 7 addtool_find_cam_id.sql \ 6 8 addtool_find_pendingexp.sql \ 9 addtool_find_processedexp.sql \ 10 addtool_pendingcleanupexp.sql \ 11 addtool_pendingcleanuprun.sql \ 7 12 addtool_queue_cam_id.sql \ 8 13 addtool_reset_faulted_runs.sql \ … … 31 36 chiptool_revertprocessedimfile.sql \ 32 37 chiptool_run.sql \ 38 chiptool_runstate.sql \ 33 39 chiptool_export_imfile.sql \ 34 40 chiptool_export_processed_imfile.sql \ … … 84 90 dettool_toresidimfile.sql \ 85 91 dettool_tostacked.sql \ 92 difftool_change_skyfile_data_state.sql \ 93 difftool_change_run_state.sql \ 86 94 difftool_completed_runs.sql \ 87 95 difftool_definewarpstack_part1.sql \ … … 145 153 faketool_unmasked.sql \ 146 154 flatcorr_chiprundone.sql \ 155 flatcorr_camerarundone.sql \ 147 156 flatcorr_pendingprocess.sql \ 148 157 flatcorr_inputimfile.sql \ … … 182 191 magicdstool_getskycells.sql \ 183 192 magicdstool_revertdestreakedfile.sql \ 193 magicdstool_tocleanup.sql \ 184 194 magicdstool_todestreak_camera.sql \ 185 195 magicdstool_todestreak_chip.sql \ … … 196 206 pstamptool_datastore.sql \ 197 207 pstamptool_listjob.sql \ 208 pstamptool_pendingdependent.sql \ 198 209 pstamptool_pendingjob.sql \ 199 210 pstamptool_pendingreq.sql \ … … 205 216 pxadmin_create_mirror_tables.sql \ 206 217 pxadmin_drop_tables.sql \ 218 pxadmin_update_version.sql \ 207 219 pubtool_definerun.sql \ 208 220 pubtool_pending.sql \ … … 263 275 warptool_revertoverlap.sql \ 264 276 warptool_revertwarped_delete.sql \ 277 warptool_runstate.sql \ 265 278 warptool_scmap.sql \ 266 279 warptool_tooverlap.sql \ -
branches/eam_branches/20090820/ippTools/share/addtool_find_pendingexp.sql
r25766 r25870 1 1 SELECT 2 2 addRun.*, 3 camProcessedExp.path_base as camroot, 3 4 rawExp.exp_tag, 4 5 rawExp.exp_id, … … 10 11 JOIN camRun 11 12 USING(cam_id) 13 JOIN camProcessedExp 14 USING(cam_id) 12 15 JOIN chipRun 13 16 USING(chip_id) 14 JOIN chipProcessedImfile15 USING(chip_id)16 17 JOIN rawExp 17 ON chipRun.exp_id = rawExp.exp_id18 USING(exp_id) 18 19 LEFT JOIN addProcessedExp 19 20 USING(add_id) … … 23 24 camRun.state = 'full' 24 25 AND ((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update') 26 AND addRun.dvodb IS NOT NULL 27 AND addRun.workdir IS NOT NULL 25 28 AND addMask.label IS NULL 26 29 -
branches/eam_branches/20090820/ippTools/share/addtool_queue_cam_id.sql
r25766 r25870 6 6 '%s', -- workdir 7 7 '%s', -- workdir_state 8 '%s', -- reduction 8 9 '%s', -- label 10 '%s', -- data_group 9 11 '%s', -- dvodb 10 0 -- magicked 12 '%s', -- note 13 %d -- image_only 11 14 FROM camRun 12 15 WHERE -
branches/eam_branches/20090820/ippTools/share/camtool_find_processedexp.sql
r24512 r25870 2 2 camProcessedExp.*, 3 3 camRun.workdir, 4 camRun.label, 4 5 chipRun.chip_id, 5 6 rawExp.exp_tag, -
branches/eam_branches/20090820/ippTools/share/camtool_queue_chip_id.sql
r24681 r25870 9 9 '%s', -- workdir_state 10 10 '%s', -- label 11 '%s', -- data_group 12 '%s', -- dist_group 11 13 '%s', -- reduction 12 14 '%s', -- expgroup … … 14 16 '%s', -- tess_id 15 17 '%s', -- end_stage 16 0 -- magicked 18 0, -- magicked 19 '%s' -- note 17 20 FROM chipRun 18 21 WHERE -
branches/eam_branches/20090820/ippTools/share/chiptool_completely_processed_exp.sql
r23688 r25870 7 7 workdir_state, 8 8 label, 9 data_group, 10 dist_group, 9 11 reduction, 10 12 expgroup, … … 12 14 tess_id, 13 15 end_stage, 14 all_files_magicked as magicked 16 all_files_magicked as magicked, 17 note 15 18 FROM 16 19 (SELECT -
branches/eam_branches/20090820/ippTools/share/chiptool_processedimfile.sql
r25127 r25870 12 12 chipRun.state, 13 13 chipRun.workdir, 14 chipRun.label, 14 15 rawExp.exp_id, 15 16 rawExp.exp_tag, -
branches/eam_branches/20090820/ippTools/share/chiptool_run.sql
r18075 r25870 2 2 chipRun.* 3 3 FROM chipRun 4 JOIN rawExp 5 USING(exp_id) -
branches/eam_branches/20090820/ippTools/share/difftool_pendingcleanuprun.sql
r24186 r25870 1 1 -- does this result in too many entries (one for each diffInputSkyfile?) 2 2 -- all of this is just to get the camera used for the diff run 3 SELECT 4 diffRun.diff_id, 5 rawExp.camera, 6 diffRun.state 7 FROM diffRun 8 JOIN diffInputSkyfile 9 USING(diff_id) 10 JOIN warpSkyfile 11 ON diffInputSkyfile.warp1 = warpSkyfile.warp_id 12 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 13 AND diffInputSkyfile.tess_id = warpSkyfile.tess_id 14 JOIN warpRun 15 ON warpRun.warp_id = warpSkyfile.warp_id 16 JOIN fakeRun 17 USING(fake_id) 18 JOIN camRun 19 USING(cam_id) 20 JOIN chipRun 21 USING(chip_id) 22 JOIN rawExp 23 USING(exp_id) 24 WHERE 25 (diffRun.state = 'goto_cleaned' OR diffRun.state = 'goto_scrubbed' OR diffRun.state = 'goto_purged') 3 SELECT DISTINCT * FROM 4 (SELECT 5 diffRun.diff_id, 6 rawExp.camera, 7 diffRun.state, 8 diffRun.label 9 FROM diffRun 10 JOIN diffInputSkyfile 11 USING(diff_id) 12 JOIN warpSkyfile 13 ON diffInputSkyfile.warp1 = warpSkyfile.warp_id 14 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 15 AND diffInputSkyfile.tess_id = warpSkyfile.tess_id 16 JOIN warpRun 17 ON warpRun.warp_id = warpSkyfile.warp_id 18 JOIN fakeRun 19 USING(fake_id) 20 JOIN camRun 21 USING(cam_id) 22 JOIN chipRun 23 USING(chip_id) 24 JOIN rawExp 25 USING(exp_id) 26 WHERE 27 (diffRun.state = 'goto_cleaned' OR 28 diffRun.state = 'goto_scrubbed' OR 29 diffRun.state = 'goto_purged') 30 UNION 31 SELECT 32 diffRun.diff_id, 33 rawExp.camera, 34 diffRun.state, 35 diffRun.label 36 FROM diffRun 37 JOIN diffInputSkyfile 38 USING(diff_id) 39 JOIN warpSkyfile 40 ON diffInputSkyfile.warp2 = warpSkyfile.warp_id 41 AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id 42 AND diffInputSkyfile.tess_id = warpSkyfile.tess_id 43 JOIN warpRun 44 ON warpRun.warp_id = warpSkyfile.warp_id 45 JOIN fakeRun 46 USING(fake_id) 47 JOIN camRun 48 USING(cam_id) 49 JOIN chipRun 50 USING(chip_id) 51 JOIN rawExp 52 USING(exp_id) 53 WHERE 54 (diffRun.state = 'goto_cleaned' OR 55 diffRun.state = 'goto_scrubbed' OR 56 diffRun.state = 'goto_purged') 57 UNION 58 SELECT 59 diffRun.diff_id, 60 rawExp.camera, 61 diffRun.state, 62 diffRun.label 63 FROM diffRun 64 JOIN diffInputSkyfile 65 USING(diff_id) 66 JOIN stackSumSkyfile 67 ON diffInputSkyfile.stack1 = stackSumSkyfile.stack_id 68 JOIN stackInputSkyfile 69 ON diffInputSkyfile.stack1 = stackInputSkyfile.stack_id 70 JOIN warpRun 71 ON warpRun.warp_id = stackInputSkyfile.warp_id 72 JOIN fakeRun 73 USING(fake_id) 74 JOIN camRun 75 USING(cam_id) 76 JOIN chipRun 77 USING(chip_id) 78 JOIN rawExp 79 USING(exp_id) 80 WHERE 81 (diffRun.state = 'goto_cleaned' OR 82 diffRun.state = 'goto_scrubbed' OR 83 diffRun.state = 'goto_purged') 84 UNION 85 SELECT 86 diffRun.diff_id, 87 rawExp.camera, 88 diffRun.state, 89 diffRun.label 90 FROM diffRun 91 JOIN diffInputSkyfile 92 USING(diff_id) 93 JOIN stackSumSkyfile 94 ON diffInputSkyfile.stack2 = stackSumSkyfile.stack_id 95 JOIN stackInputSkyfile 96 ON diffInputSkyfile.stack2 = stackInputSkyfile.stack_id 97 JOIN warpRun 98 ON warpRun.warp_id = stackInputSkyfile.warp_id 99 JOIN fakeRun 100 USING(fake_id) 101 JOIN camRun 102 USING(cam_id) 103 JOIN chipRun 104 USING(chip_id) 105 JOIN rawExp 106 USING(exp_id) 107 WHERE 108 (diffRun.state = 'goto_cleaned' OR 109 diffRun.state = 'goto_scrubbed' OR 110 diffRun.state = 'goto_purged') 111 ) as Foo 112 WHERE 1 -
branches/eam_branches/20090820/ippTools/share/difftool_skyfile.sql
r25766 r25870 5 5 diffRun.state, 6 6 diffRun.workdir, 7 diffRun.label, 7 8 diffRun.bothways, 8 9 warp1, -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_camera.sql
r25766 r25870 4 4 rawExp.exp_name as run_tag, 5 5 camRun.magicked, 6 distTarget.label, 6 camRun.label, 7 distTarget.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean … … 12 13 JOIN distTarget ON distTarget.stage = 'camera' 13 14 AND rawExp.filter = distTarget.filter 14 AND camRun. label = distTarget.label15 AND camRun.dist_group = distTarget.dist_group 15 16 JOIN rcInterest USING(target_id) 16 17 LEFT JOIN distRun ON distRun.stage = 'camera' -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_chip.sql
r25766 r25870 5 5 rawExp.exp_name as run_tag, 6 6 chipRun.label, 7 chipRun.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean … … 10 11 JOIN rawExp USING(exp_id) 11 12 JOIN distTarget ON distTarget.stage = 'chip' 12 AND chipRun. label = distTarget.label13 AND chipRun.dist_group = distTarget.dist_group 13 14 AND rawExp.filter = distTarget.filter 14 15 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_diff.sql
r25766 r25870 4 4 diffRun.magicked, 5 5 rawExp.exp_name as run_tag, 6 distTarget.label, 6 diffRun.label, 7 distTarget.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean … … 15 16 JOIN rawExp USING(exp_id) 16 17 JOIN distTarget ON distTarget.stage = 'diff' 17 AND diffRun. label = distTarget.label18 AND diffRun.dist_group = distTarget.dist_group 18 19 AND distTarget.filter = rawExp.filter 19 20 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_fake.sql
r25766 r25870 4 4 CAST(0 AS SIGNED) AS magicked, 5 5 rawExp.exp_name as run_tag, 6 distTarget.label, 6 fakeRun.label, 7 distTarget.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean … … 11 12 JOIN chipRun USING(chip_id) 12 13 JOIN rawExp USING(exp_id) 13 JOIN distTarget ON distTarget.stage = 'fake' AND fakeRun. label = distTarget.label14 JOIN distTarget ON distTarget.stage = 'fake' AND fakeRun.dist_group = distTarget.dist_group 14 15 AND rawExp.filter = distTarget.filter 15 16 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_raw.sql
r25766 r25870 4 4 rawExp.exp_name AS run_tag, 5 5 rawExp.magicked, 6 distTarget.label, 6 chipRun.label, 7 distTarget.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean 9 10 FROM rawExp 10 11 JOIN chipRun USING(exp_id) 11 JOIN distTarget ON distTarget. label = chipRun.labelAND distTarget.stage = 'raw'12 JOIN distTarget ON distTarget.dist_group = chipRun.dist_group AND distTarget.stage = 'raw' 12 13 AND rawExp.filter = distTarget.filter 13 14 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_stack.sql
r25766 r25870 5 5 -- run tag in the form 'stack.$skycell_id.$stack_id' 6 6 CONCAT_WS('.', 'stack', stackRun.skycell_id, convert(stackRun.stack_id, CHAR)) as run_tag, 7 distTarget.label, 7 stackRun.label, 8 distTarget.dist_group, 8 9 distTarget.target_id, 9 10 distTarget.clean … … 11 12 JOIN stackSumSkyfile USING(stack_id) 12 13 JOIN distTarget ON distTarget.stage = 'stack' 13 AND stackRun. label = distTarget.label14 AND stackRun.dist_group = distTarget.dist_group 14 15 AND stackRun.filter = distTarget.filter 15 16 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_definebyquery_warp.sql
r25766 r25870 4 4 warpRun.magicked, 5 5 rawExp.exp_name as run_tag, 6 distTarget.label, 6 warpRun.label, 7 distTarget.dist_group, 7 8 distTarget.target_id, 8 9 distTarget.clean … … 13 14 JOIN rawExp USING(exp_id) 14 15 JOIN distTarget ON distTarget.stage = 'warp' 15 AND warpRun. label = distTarget.label16 AND warpRun.dist_group = distTarget.dist_group 16 17 AND rawExp.filter = distTarget.filter 17 18 JOIN rcInterest USING(target_id) -
branches/eam_branches/20090820/ippTools/share/disttool_defineinterest.sql
r25766 r25870 1 1 INSERT INTO rcInterest 2 SELECT 0, dest_id,target_id, '@STATE@'2 SELECT 0, rcDestination.dest_id, distTarget.target_id, '@STATE@' 3 3 FROM distTarget 4 4 JOIN rcDestination -
branches/eam_branches/20090820/ippTools/share/disttool_pending_camera.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 16 17 chipRun.magicked 17 18 FROM distRun 19 JOIN distTarget USING(target_id, stage, clean) 18 20 JOIN camRun ON camRun.cam_id = distRun.stage_id 19 21 JOIN camProcessedExp USING(cam_id) -
branches/eam_branches/20090820/ippTools/share/disttool_pending_chip.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, 6 7 chipProcessedImfile.class_id AS component, 7 clean,8 distRun.clean, 8 9 rawExp.camera, 9 10 CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir, … … 16 17 chipProcessedImfile.magicked 17 18 FROM distRun 19 JOIN distTarget USING(target_id, stage, clean) 18 20 JOIN chipRun ON chipRun.chip_id = distRun.stage_id 19 21 JOIN rawExp using(exp_id) -
branches/eam_branches/20090820/ippTools/share/disttool_pending_diff.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 18 19 diffSkyfile.magicked 19 20 FROM distRun 21 JOIN distTarget USING(target_id, stage, clean) 20 22 JOIN diffRun ON stage_id = diff_id 21 23 JOIN diffSkyfile using(diff_id) -
branches/eam_branches/20090820/ippTools/share/disttool_pending_fake.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 16 17 0 17 18 FROM distRun 19 JOIN distTarget USING(target_id, stage, clean) 18 20 JOIN fakeRun ON fakeRun.fake_id = distRun.stage_id 19 21 JOIN fakeProcessedImfile USING(fake_id) -
branches/eam_branches/20090820/ippTools/share/disttool_pending_raw.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 16 17 rawImfile.magicked 17 18 FROM distRun 19 JOIN distTarget USING(target_id, stage, clean) 18 20 JOIN rawExp ON rawExp.exp_id = stage_id 19 21 JOIN rawImfile USING(exp_id) … … 35 37 distRun.dist_id, 36 38 distRun.label, 39 distTarget.dist_group, 37 40 stage, 38 41 stage_id, … … 49 52 rawExp.magicked 50 53 FROM distRun 54 JOIN distTarget USING(target_id, stage, clean) 51 55 JOIN rawExp ON exp_id = stage_id 52 56 LEFT JOIN distComponent -
branches/eam_branches/20090820/ippTools/share/disttool_pending_stack.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 18 19 0 AS magicked 19 20 FROM distRun 21 JOIN distTarget USING(target_id, stage, clean) 20 22 JOIN stackRun 21 23 ON stage_id = stack_id -
branches/eam_branches/20090820/ippTools/share/disttool_pending_warp.sql
r25766 r25870 2 2 distRun.dist_id, 3 3 distRun.label, 4 distTarget.dist_group, 4 5 stage, 5 6 stage_id, … … 16 17 warpSkyfile.magicked 17 18 FROM distRun 19 JOIN distTarget USING(target_id, stage, clean) 18 20 JOIN warpRun ON stage_id = warp_id 19 21 JOIN warpSkyfile using(warp_id) -
branches/eam_branches/20090820/ippTools/share/disttool_pendingfileset.sql
r25766 r25870 4 4 distRun.stage, 5 5 stage_id, 6 distTarget. label,6 distTarget.dist_group, 7 7 distTarget.filter, 8 8 CONCAT_WS('.', distRun.outroot, CONVERT(distRun.dist_id, CHAR)) as dist_dir, -
branches/eam_branches/20090820/ippTools/share/faketool_completely_processed_exp.sql
r20608 r25870 6 6 workdir, 7 7 label, 8 data_group, 9 dist_group, 8 10 reduction, 9 11 expgroup, … … 11 13 tess_id, 12 14 end_stage, 13 epoch 15 epoch, 16 note 14 17 FROM 15 18 (SELECT -
branches/eam_branches/20090820/ippTools/share/faketool_queue_cam_id.sql
r19092 r25870 6 6 '%s', -- workdir 7 7 '%s', -- label 8 '%s', -- data_group 9 '%s', -- dist_group 8 10 '%s', -- reduction 9 11 '%s', -- expgroup … … 11 13 '%s', -- tess_id 12 14 '%s', -- end_stage 13 NULL -- epoch 15 NULL, -- epoch 16 '%s' -- note 14 17 FROM camRun 15 18 WHERE -
branches/eam_branches/20090820/ippTools/share/flatcorr_chiprundone.sql
r20397 r25870 1 1 SELECT 2 2 corr_id, 3 cam_id,4 3 chipRun.* 5 4 FROM flatcorrRun … … 14 13 AND flatcorrChipLink.include = 1 15 14 AND chipRun.state = 'full' 16 AND camRun.cam_id is NULL ;15 AND camRun.cam_id is NULL -
branches/eam_branches/20090820/ippTools/share/flatcorr_pendingprocess.sql
r20397 r25870 10 10 reduction, 11 11 region, 12 c hip_count,13 cam_count12 cam_count, 13 add_count 14 14 FROM 15 15 (SELECT 16 16 flatcorrRun.*, 17 flatcorrC hipLink.corr_id as chip_corr_id,18 count(flatcorrC hipLink.chip_id) as chip_count17 flatcorrCamLink.corr_id as cam_corr_id, 18 count(flatcorrCamLink.cam_id) as cam_count 19 19 FROM flatcorrRun 20 JOIN flatcorrC hipLink21 ON flatcorrChipLink.corr_id = flatcorrRun.corr_id22 WHERE flatcorrC hipLink.include = 120 JOIN flatcorrCamLink 21 USING (corr_id) 22 WHERE flatcorrCamLink.include = 1 23 23 GROUP BY 24 flatcorrC hipLink.corr_id) AS t124 flatcorrCamLink.corr_id) AS t1 25 25 LEFT JOIN 26 26 (SELECT 27 flatcorr CamLink.corr_id as cam_corr_id,28 count(flatcorr CamLink.cam_id) as cam_count29 FROM flatcorr CamLink30 JOIN camRun31 ON flatcorrCamLink.cam_id = camRun.cam_id32 WHERE camRun.state = 'full'33 AND flatcorr CamLink.include = 127 flatcorrAddstarLink.corr_id as add_corr_id, 28 count(flatcorrAddstarLink.add_id) as add_count 29 FROM flatcorrAddstarLink 30 JOIN addRun 31 USING (add_id) 32 WHERE addRun.state = 'full' 33 AND flatcorrAddstarLink.include = 1 34 34 GROUP BY 35 flatcorr CamLink.corr_id) AS t236 ON t1.c hip_corr_id = t2.cam_corr_id37 WHERE c hip_count = cam_count35 flatcorrAddstarLink.corr_id) AS t2 36 ON t1.cam_corr_id = t2.add_corr_id 37 WHERE cam_count = add_count 38 38 AND state = 'new' -
branches/eam_branches/20090820/ippTools/share/pstamptool_pendingjob.sql
r25766 r25870 1 1 SELECT pstampJob.* 2 2 FROM pstampJob 3 JOIN pstampRequest using(req_id) 3 JOIN pstampRequest USING(req_id) 4 LEFT JOIN pstampDependent USING(dep_id) 4 5 WHERE pstampRequest.state = 'run' 5 6 AND pstampRequest.fault = 0 6 7 AND pstampJob.state = 'run' 7 8 AND pstampJob.fault = 0 9 AND (dep_id = 0 OR pstampDependent.state = 'full') -
branches/eam_branches/20090820/ippTools/share/pxadmin_create_tables.sql
r25766 r25870 1 CREATE TABLE dbversion ( 2 schema_version VARCHAR(64), 3 updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP 4 ) ENGINE=innodb DEFAULT CHARSET=latin1; 5 1 6 CREATE TABLE pzDataStore ( 2 7 camera VARCHAR(64), … … 261 266 workdir_state VARCHAR(64), 262 267 label VARCHAR(64), 268 data_group VARCHAR(64), 269 dist_group VARCHAR(64), 263 270 reduction VARCHAR(64), 264 expgroup VARCHAR(64),271 expgroup VARCHAR(64), 265 272 dvodb VARCHAR(255), 266 273 tess_id VARCHAR(64), 267 274 end_stage VARCHAR(64), 268 275 magicked BIGINT, 276 note VARCHAR(255), 269 277 PRIMARY KEY(chip_id), 270 278 KEY(chip_id), KEY(exp_id), … … 272 280 KEY(workdir_state), 273 281 KEY(label), 282 KEY(data_group), 283 KEY(dist_group), 274 284 KEY(expgroup), 275 285 KEY(end_stage), … … 367 377 workdir_state VARCHAR(64), 368 378 label VARCHAR(64), 379 data_group VARCHAR(64), 380 dist_group VARCHAR(64), 369 381 reduction VARCHAR(64), 370 382 expgroup VARCHAR(64), … … 373 385 end_stage VARCHAR(64), 374 386 magicked BIGINT, 387 note VARCHAR(255), 375 388 PRIMARY KEY(cam_id), 376 389 KEY(cam_id), … … 379 392 KEY(workdir_state), 380 393 KEY(label), 394 KEY(data_group), 395 KEY(dist_group), 381 396 KEY(expgroup), 382 397 KEY(end_stage), … … 464 479 workdir VARCHAR(255), 465 480 workdir_state VARCHAR(64), 481 reduction VARCHAR(64), 466 482 label VARCHAR(64), 483 data_group VARCHAR(64), 467 484 dvodb VARCHAR(255), 468 magicked BIGINT, 485 note VARCHAR(255), 486 image_only TINYINT, 469 487 PRIMARY KEY(add_id), 470 488 KEY(add_id), … … 473 491 KEY(workdir_state), 474 492 KEY(label), 493 KEY(data_group), 475 494 INDEX(add_id, cam_id), 476 495 FOREIGN KEY(cam_id) REFERENCES camRun(cam_id) … … 480 499 add_id BIGINT AUTO_INCREMENT, 481 500 dtime_addstar FLOAT, 482 n_stars INT,483 501 path_base VARCHAR(255), 484 502 fault SMALLINT NOT NULL, … … 498 516 workdir VARCHAR(255), 499 517 label VARCHAR(64), 518 data_group VARCHAR(64), 519 dist_group VARCHAR(64), 500 520 reduction VARCHAR(64), 501 521 expgroup VARCHAR(64), … … 504 524 end_stage VARCHAR(64), 505 525 epoch TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 526 note VARCHAR(255), 506 527 PRIMARY KEY(fake_id), 507 528 KEY(cam_id), 508 529 KEY(state), 509 530 KEY(label), 531 KEY(data_group), 532 KEY(dist_group), 510 533 KEY(expgroup), 511 534 KEY(end_stage), … … 834 857 workdir_state VARCHAR(64), 835 858 label VARCHAR(64), 859 data_group VARCHAR(64), 860 dist_group VARCHAR(64), 836 861 dvodb VARCHAR(255), 837 862 tess_id VARCHAR(64), … … 840 865 registered DATETIME, 841 866 magicked BIGINT, 867 note VARCHAR(255), 842 868 PRIMARY KEY(warp_id), 843 869 KEY(warp_id), … … 847 873 KEY(workdir_state), 848 874 KEY(label), 875 KEY(data_group), 876 KEY(dist_group), 849 877 KEY(end_stage), 850 878 INDEX(warp_id, fake_id), … … 910 938 workdir VARCHAR(255), 911 939 label VARCHAR(64), 940 data_group VARCHAR(64), 941 dist_group VARCHAR(64), 912 942 reduction VARCHAR(64), 913 943 dvodb VARCHAR(255), … … 916 946 tess_id VARCHAR(64), 917 947 filter VARCHAR(64), 948 note VARCHAR(255), 918 949 PRIMARY KEY(stack_id), 919 950 KEY(stack_id), … … 921 952 KEY(skycell_id), 922 953 KEY(tess_id), 923 KEY(label) 954 KEY(label), 955 KEY(data_group), 956 KEY(dist_group) 924 957 ) ENGINE=innodb DEFAULT CHARSET=latin1; 925 958 … … 973 1006 workdir VARCHAR(255), 974 1007 label VARCHAR(64), 1008 data_group VARCHAR(64), 1009 dist_group VARCHAR(64), 975 1010 reduction VARCHAR(64), 976 1011 dvodb VARCHAR(255), … … 980 1015 exposure TINYINT DEFAULT 0, 981 1016 magicked BIGINT, 1017 note VARCHAR(255), 982 1018 PRIMARY KEY(diff_id), 983 1019 KEY(diff_id), 984 1020 KEY(state), 985 1021 KEY(tess_id), 986 KEY(label) 1022 KEY(label), 1023 KEY(data_group), 1024 KEY(dist_group) 987 1025 ) ENGINE=innodb DEFAULT CHARSET=latin1; 988 1026 … … 1055 1093 workdir_state VARCHAR(255), 1056 1094 label VARCHAR(64), 1095 data_group VARCHAR(64), 1057 1096 dvodb VARCHAR(255), 1058 1097 registered DATETIME, 1059 1098 fault SMALLINT, 1099 note VARCHAR(255), 1060 1100 PRIMARY KEY(magic_id), 1061 1101 KEY(magic_id), … … 1063 1103 KEY(workdir_state), 1064 1104 KEY(label), 1105 KEY(data_group), 1065 1106 KEY(fault), 1066 1107 FOREIGN KEY(exp_id) REFERENCES rawExp(exp_id), … … 1118 1159 cam_id BIGINT, 1119 1160 label VARCHAR(64), 1161 data_group VARCHAR(64), 1120 1162 outroot VARCHAR(255), 1121 1163 recoveryroot VARCHAR(255), 1122 1164 re_place TINYINT, 1123 1165 remove TINYINT, 1166 fault SMALLINT, 1167 note VARCHAR(255), 1124 1168 PRIMARY KEY(magic_ds_id), 1125 1169 KEY(magic_ds_id), … … 1127 1171 KEY(magic_id), 1128 1172 KEY(label), 1173 KEY(fault), 1129 1174 FOREIGN KEY(magic_id) REFERENCES magicRun(magic_id), 1130 1175 FOREIGN KEY(inv_magic_id) REFERENCES magicRun(magic_id) … … 1182 1227 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1183 1228 1184 -- these t wo tables link the flatcorrRun to the associated chip and cameraruns1229 -- these three tables link the flatcorrRun to the associated chip, camera, and addstar runs 1185 1230 CREATE TABLE flatcorrChipLink ( 1186 1231 corr_id BIGINT, … … 1201 1246 FOREIGN KEY(chip_id) REFERENCES chipRun(chip_id), 1202 1247 FOREIGN KEY(cam_id) REFERENCES camRun(cam_id) 1248 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1249 1250 CREATE TABLE flatcorrAddstarLink ( 1251 corr_id BIGINT, 1252 cam_id BIGINT, 1253 add_id BIGINT, 1254 include TINYINT, 1255 PRIMARY KEY(corr_id, cam_id, add_id), 1256 FOREIGN KEY (corr_id) REFERENCES flatcorrRun(corr_id), 1257 FOREIGN KEY (cam_id) REFERENCES camRun(cam_id), 1258 FOREIGN KEY (add_id) REFERENCES addRun(add_id) 1203 1259 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1204 1260 … … 1250 1306 outputBase VARCHAR(255), 1251 1307 options BIGINT, 1308 dep_id BIGINT, 1252 1309 PRIMARY KEY(job_id, req_id), 1253 1310 KEY(job_id), … … 1255 1312 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1256 1313 1314 CREATE TABLE pstampDependent ( 1315 dep_id BIGINT AUTO_INCREMENT, 1316 state VARCHAR(64), 1317 stage VARCHAR(64), 1318 stage_id BIGINT, 1319 imagedb VARCHAR(64), 1320 rlabel VARCHAR(64), 1321 no_magic TINYINT, 1322 PRIMARY KEY(dep_id) 1323 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1324 1257 1325 CREATE TABLE distTarget ( 1258 1326 target_id BIGINT AUTO_INCREMENT, 1259 labelVARCHAR(64),1327 dist_group VARCHAR(64), 1260 1328 filter VARCHAR(64), 1261 1329 stage VARCHAR(64), … … 1264 1332 comment VARCHAR(255), 1265 1333 PRIMARY KEY(target_id), 1266 CONSTRAINT UNIQUE ( label, filter, stage, clean)1334 CONSTRAINT UNIQUE (dist_group, filter, stage, clean) 1267 1335 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1268 1336 … … 1280 1348 time_stamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 1281 1349 fault SMALLINT, 1350 note VARCHAR(255), 1282 1351 PRIMARY KEY(dist_id), 1283 1352 KEY(state), -
branches/eam_branches/20090820/ippTools/share/pxadmin_drop_tables.sql
r25766 r25870 1 1 SET FOREIGN_KEY_CHECKS=0; 2 2 3 DROP TABLE IF EXISTS dbversion; 3 4 DROP TABLE IF EXISTS pzDataStore; 4 5 DROP TABLE IF EXISTS summitExp; … … 59 60 DROP TABLE IF EXISTS flatcorrChipLink; 60 61 DROP TABLE IF EXISTS flatcorrCamLink; 62 DROP TABLE IF EXISTS flatcorrAddstarLink; 61 63 DROP TABLE IF EXISTS pstampDataStore; 62 64 DROP TABLE IF EXISTS pstampProject; … … 78 80 DROP TABLE IF EXISTS publishRun; 79 81 DROP TABLE IF EXISTS publishDone; 82 DROP TABLE IF EXISTS pstampDependent; 80 83 81 84 SET FOREIGN_KEY_CHECKS=1 -
branches/eam_branches/20090820/ippTools/share/warptool_warped.sql
r24112 r25870 3 3 warpRun.state, 4 4 warpRun.workdir, 5 warpRun.label, 5 6 warpImfile.warp_skyfile_id, 6 7 rawExp.exp_id, -
branches/eam_branches/20090820/ippTools/src/Makefile.am
r25766 r25870 34 34 pxmagic.h \ 35 35 pxregister.h \ 36 pxspace.h \ 36 37 pxtag.h \ 37 38 pxtools.h \ … … 78 79 pxmagic.c \ 79 80 pxregister.c \ 81 pxspace.c \ 80 82 pxtag.c \ 81 83 pxtools.c \ -
branches/eam_branches/20090820/ippTools/src/addtool.c
r25766 r25870 40 40 static bool maskedMode(pxConfig *config); 41 41 static bool unblockMode(pxConfig *config); 42 static bool pendingcleanuprunMode(pxConfig *config);43 static bool pendingcleanupexpMode(pxConfig *config);44 static bool donecleanupMode(pxConfig *config);45 static bool exportrunMode(pxConfig *config);46 static bool importrunMode(pxConfig *config);47 42 48 43 # define MODECASE(caseName, func) \ … … 74 69 MODECASE(ADDTOOL_MODE_MASKED, maskedMode); 75 70 MODECASE(ADDTOOL_MODE_UNBLOCK, unblockMode); 76 MODECASE(ADDTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode);77 MODECASE(ADDTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpMode);78 MODECASE(ADDTOOL_MODE_DONECLEANUP, donecleanupMode);79 MODECASE(ADDTOOL_MODE_EXPORTRUN, exportrunMode);80 MODECASE(ADDTOOL_MODE_IMPORTRUN, importrunMode);81 71 default: 82 72 psAbort("invalid option (this should not happen)"); … … 106 96 107 97 psMetadata *where = psMetadataAlloc(); 108 pxaddGetSearchArgs (config, where); 109 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 110 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 98 pxcamGetSearchArgs (config, where); 99 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 100 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 101 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 111 102 112 103 if (!psListLength(where->list) && … … 117 108 } 118 109 119 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 120 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 121 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 122 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 110 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 111 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 112 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 113 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 114 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 115 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 116 PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false); 117 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 118 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 123 119 124 120 // find the cam_id of all the exposures that we want to queue up. … … 130 126 } 131 127 132 // use psDBGenerateWhere SQL because the SQL yields an intermediate table128 // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE 133 129 if (where && psListLength(where->list)) { 134 130 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); … … 136 132 psFree(whereClause); 137 133 } 138 139 134 psFree(where); 140 135 … … 155 150 psFree(output); 156 151 return true; 152 } 153 154 if (pretend) { 155 // negative simple so the default is true 156 if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) { 157 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 158 psFree(output); 159 return false; 160 } 161 psFree(output); 162 return true; 163 } 164 165 // loop over our list of camRun rows to check the supplied and selected dvodb and workdir values: 166 for (long i = 0; i < psArrayLength(output); i++) { 167 psMetadata *md = output->data[i]; 168 169 camRunRow *row = camRunObjectFromMetadata(md); 170 if (!row) { 171 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 172 psFree(output); 173 return false; 174 } 175 176 if (!dvodb && !row->dvodb) { 177 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id); 178 psFree(output); 179 return false; 180 } 181 if (!workdir && !row->workdir) { 182 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id); 183 psFree(output); 184 return false; 185 } 186 187 psFree(row); 157 188 } 158 189 … … 170 201 // old values in place (i.e., passing the values through). 171 202 172 173 // loop over our list of addRun rows 203 // loop over our list of camRun rows 174 204 for (long i = 0; i < psArrayLength(output); i++) { 175 205 psMetadata *md = output->data[i]; 176 206 177 addRunRow *row = addRunObjectFromMetadata(md);207 camRunRow *row = camRunObjectFromMetadata(md); 178 208 if (!row) { 179 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into addRun");209 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 180 210 psFree(output); 181 211 return false; … … 186 216 row->cam_id, 187 217 workdir ? workdir : row->workdir, 218 reduction ? reduction : row->reduction, 188 219 label ? label : row->label, 189 "RECIPE", 190 dvodb ? dvodb : row->dvodb 191 220 data_group ? data_group : (label ? label : row->label), 221 dvodb ? dvodb : row->dvodb, 222 note ? note : NULL, 223 image_only 192 224 )) { 193 225 if (!psDBRollback(config->dbh)) { … … 218 250 219 251 psMetadata *where = psMetadataAlloc(); 220 pxaddGetSearchArgs (config, where);221 252 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 253 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 254 pxcamGetSearchArgs (config, where); // most search arguments based on camera 222 255 PXOPT_COPY_STR(config->args, where, "-label", "addRun.label", "=="); 223 256 PXOPT_COPY_STR(config->args, where, "-state", "addRun.state", "=="); 224 257 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 225 258 226 if (!psListLength(where->list) 227 && !psMetadataLookupBool(NULL, config->args, "-all")) { 259 if (!psListLength(where->list)) { 228 260 psFree(where); 229 261 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); … … 231 263 } 232 264 265 psString query = psStringCopy("UPDATE addRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 266 267 // pxUpdateRun gets parameters from config->args and runs the update query 268 bool result = pxUpdateRun(config, where, &query, "addRun", false); 269 270 psFree(query); 271 psFree(where); 272 273 return result; 274 275 276 #ifdef notdef 233 277 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 234 278 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); … … 259 303 260 304 return true; 305 #endif 261 306 } 262 307 … … 267 312 268 313 psMetadata *where = psMetadataAlloc(); 269 pxaddGetSearchArgs (config, where);270 314 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 315 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 316 pxcamGetSearchArgs (config, where); 271 317 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 272 318 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 273 274 319 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 275 320 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 325 370 } 326 371 327 /* static bool pendingimfileMode(pxConfig *config) */328 /* { */329 /* PS_ASSERT_PTR_NON_NULL(config, false); */330 331 /* psMetadata *where = psMetadataAlloc(); */332 /* pxaddGetSearchArgs (config, where); */333 /* PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); */334 /* pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); */335 /* PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); */336 /* PXOPT_COPY_S64(config->args, where, "-chip_id", "addRun.chip_id", "=="); */337 /* PXOPT_COPY_STR(config->args, where, "-class_id", "addProcessedExp.class_id", "=="); */338 339 /* PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); */340 341 /* psString query = pxDataGet("addtool_find_pendingimfile.sql"); */342 /* if (!query) { */343 /* psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); */344 /* return false; */345 /* } */346 347 /* // use psDBGenerateWhereSQL because the SQL yields an intermediate table */348 /* if (psListLength(where->list)) { */349 /* psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); */350 /* psStringAppend(&query, " AND %s", whereClause); */351 /* psFree(whereClause); */352 /* } */353 /* psFree(where); */354 355 /* if (!p_psDBRunQuery(config->dbh, query)) { */356 /* psError(PS_ERR_UNKNOWN, false, "database error"); */357 /* psFree(query); */358 /* return false; */359 /* } */360 /* psFree(query); */361 362 /* psArray *output = p_psDBFetchResult(config->dbh); */363 /* if (!output) { */364 /* psError(PS_ERR_UNKNOWN, false, "database error"); */365 /* return false; */366 /* } */367 /* if (!psArrayLength(output)) { */368 /* psTrace("addtool", PS_LOG_INFO, "no rows found"); */369 /* psFree(output); */370 /* return true; */371 /* } */372 373 /* // negate simple so the default is true */374 /* if (!ippdbPrintMetadatas(stdout, output, "addProcessedExp", !simple)) { */375 /* psError(PS_ERR_UNKNOWN, false, "failed to print array"); */376 /* psFree(output); */377 /* return false; */378 /* } */379 380 /* psFree(output); */381 382 /* return true; */383 /* } */384 385 372 static bool addprocessedexpMode(pxConfig *config) 386 373 { … … 391 378 392 379 // optional 393 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false); 394 395 PXOPT_LOOKUP_S32(n_stars, config->args, "-n_stars", false, false); 396 397 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 398 399 PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 380 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 381 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false); 382 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 400 383 401 384 // generate restrictions … … 446 429 pendingRow->add_id, 447 430 dtime_addstar, 448 n_stars,449 431 path_base, 450 0432 fault 451 433 ); 452 434 … … 463 445 464 446 // since there is only one exp per 'new' set addRun.state = 'full' 465 if (!pxaddRunSetState(config, row->add_id, "full" , magicked)) {447 if (!pxaddRunSetState(config, row->add_id, "full")) { 466 448 psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id); 467 449 psFree(row); … … 469 451 return false; 470 452 } 471 472 // NULL for end_stage means go as far as possible473 // EAM : skip here if fault != 0474 // Also, we can run fake even if tess_id is not defined475 /* if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "add"))) { */476 /* psFree(row); */477 /* psFree(pendingRow); */478 /* if (!psDBCommit(config->dbh)) { */479 /* psError(PS_ERR_UNKNOWN, false, "database error"); */480 /* return false; */481 /* } */482 /* return true; */483 /* } */484 453 psFree(row); 485 // else continue on...486 487 /* if (!pxfakeQueueByAddID(config, */488 /* pendingRow->add_id, */489 /* pendingRow->workdir, */490 /* pendingRow->label, */491 /* pendingRow->reduction, */492 /* pendingRow->expgroup, */493 /* pendingRow->dvodb, */494 /* pendingRow->tess_id, */495 /* pendingRow->end_stage */496 /* )) { */497 /* // rollback */498 /* if (!psDBRollback(config->dbh)) { */499 /* psError(PS_ERR_UNKNOWN, false, "database error"); */500 /* } */501 /* psError(PS_ERR_UNKNOWN, false, "failed to queue new fakeRun"); */502 /* psFree(pendingRow); */503 /* return false; */504 /* } */505 454 psFree(pendingRow); 506 455 … … 517 466 { 518 467 PS_ASSERT_PTR_NON_NULL(config, false); 468 469 // generate restrictions 470 psMetadata *where = psMetadataAlloc(); 471 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 472 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 473 pxcamGetSearchArgs (config, where); 474 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 475 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 519 476 520 477 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 521 478 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 522 479 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 523 524 // generate restrictions525 psMetadata *where = psMetadataAlloc();526 pxaddGetSearchArgs (config, where);527 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "==");528 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");529 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");530 480 531 481 if (!psListLength(where->list) && … … 613 563 614 564 psMetadata *where = psMetadataAlloc(); 615 pxaddGetSearchArgs (config, where);616 565 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 566 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 567 pxcamGetSearchArgs (config, where); 617 568 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 618 569 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 619 /* PXOPT_COPY_S16(config->args, where, "-fault", "addProcessedExp.fault", "=="); */620 570 621 571 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { … … 705 655 PS_ASSERT_PTR_NON_NULL(config, false); 706 656 707 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);708 709 657 psMetadata *where = psMetadataAlloc(); 710 658 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "=="); 711 659 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 712 /* PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); */ 713 /* PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); */ 660 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 714 661 715 662 if (!pxSetFaultCode(config->dbh, "addProcessedExp", where, fault)) { … … 777 724 } 778 725 779 780 726 static bool unblockMode(pxConfig *config) 781 727 { … … 793 739 return true; 794 740 } 795 796 static bool pendingcleanuprunMode(pxConfig *config)797 {798 PS_ASSERT_PTR_NON_NULL(config, NULL);799 800 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);801 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);802 803 psMetadata *where = psMetadataAlloc();804 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");805 806 psString query = pxDataGet("addtool_pendingcleanuprun.sql");807 if (!query) {808 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");809 return false;810 }811 812 if (where && psListLength(where->list)) {813 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);814 psStringAppend(&query, " AND %s", whereClause);815 psFree(whereClause);816 }817 psFree(where);818 819 // treat limit == 0 as "no limit"820 if (limit) {821 psString limitString = psDBGenerateLimitSQL(limit);822 psStringAppend(&query, " %s", limitString);823 psFree(limitString);824 }825 826 if (!p_psDBRunQuery(config->dbh, query)) {827 psError(PS_ERR_UNKNOWN, false, "database error");828 psFree(query);829 return false;830 }831 psFree(query);832 833 psArray *output = p_psDBFetchResult(config->dbh);834 if (!output) {835 psError(PS_ERR_UNKNOWN, false, "database error");836 return false;837 }838 if (!psArrayLength(output)) {839 psTrace("addtool", PS_LOG_INFO, "no rows found");840 psFree(output);841 return true;842 }843 844 // negative simple so the default is true845 if (!ippdbPrintMetadatas(stdout, output, "addPendingCleanupRun", !simple)) {846 psError(PS_ERR_UNKNOWN, false, "failed to print array");847 psFree(output);848 return false;849 }850 851 psFree(output);852 853 return true;854 }855 856 857 static bool pendingcleanupexpMode(pxConfig *config)858 {859 PS_ASSERT_PTR_NON_NULL(config, NULL);860 861 PXOPT_LOOKUP_S64(add_id, config->args, "-add_id", false, false);862 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);863 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);864 865 psMetadata *where = psMetadataAlloc();866 if (add_id) {867 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "==");868 }869 pxAddLabelSearchArgs (config, where, "-label", "label", "==");870 871 psString query = pxDataGet("addtool_pendingcleanupexp.sql");872 if (!query) {873 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");874 return false;875 }876 877 if (where && psListLength(where->list)) {878 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);879 psStringAppend(&query, " AND %s", whereClause);880 psFree(whereClause);881 }882 psFree(where);883 884 // treat limit == 0 as "no limit"885 if (limit) {886 psString limitString = psDBGenerateLimitSQL(limit);887 psStringAppend(&query, " %s", limitString);888 psFree(limitString);889 }890 891 if (!p_psDBRunQuery(config->dbh, query)) {892 psError(PS_ERR_UNKNOWN, false, "database error");893 psFree(query);894 return false;895 }896 psFree(query);897 898 psArray *output = p_psDBFetchResult(config->dbh);899 if (!output) {900 psError(PS_ERR_UNKNOWN, false, "database error");901 return false;902 }903 if (!psArrayLength(output)) {904 psTrace("chiptool", PS_LOG_INFO, "no rows found");905 psFree(output);906 return true;907 }908 909 // negative simple so the default is true910 if (!ippdbPrintMetadatas(stdout, output, "addPendingCleanupExp", !simple)) {911 psError(PS_ERR_UNKNOWN, false, "failed to print array");912 psFree(output);913 return false;914 }915 916 psFree(output);917 918 return true;919 }920 921 922 static bool donecleanupMode(pxConfig *config)923 {924 PS_ASSERT_PTR_NON_NULL(config, NULL);925 926 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);927 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);928 929 psMetadata *where = psMetadataAlloc();930 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");931 932 psString query = pxDataGet("addtool_donecleanup.sql");933 if (!query) {934 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");935 return false;936 }937 938 if (where && psListLength(where->list)) {939 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);940 psStringAppend(&query, " AND %s", whereClause);941 psFree(whereClause);942 }943 psFree(where);944 945 // treat limit == 0 as "no limit"946 if (limit) {947 psString limitString = psDBGenerateLimitSQL(limit);948 psStringAppend(&query, " %s", limitString);949 psFree(limitString);950 }951 952 if (!p_psDBRunQuery(config->dbh, query)) {953 psError(PS_ERR_UNKNOWN, false, "database error");954 psFree(query);955 return false;956 }957 psFree(query);958 959 psArray *output = p_psDBFetchResult(config->dbh);960 if (!output) {961 psError(PS_ERR_UNKNOWN, false, "database error");962 return false;963 }964 if (!psArrayLength(output)) {965 psTrace("addtool", PS_LOG_INFO, "no rows found");966 psFree(output);967 return true;968 }969 970 // negative simple so the default is true971 if (!ippdbPrintMetadatas(stdout, output, "addDoneCleanup", !simple)) {972 psError(PS_ERR_UNKNOWN, false, "failed to print array");973 psFree(output);974 return false;975 }976 977 psFree(output);978 979 return true;980 }981 982 bool exportrunMode(pxConfig *config)983 {984 typedef struct ExportTable {985 char tableName[80];986 char sqlFilename[80];987 } ExportTable;988 989 int numExportTables = 2;990 991 PS_ASSERT_PTR_NON_NULL(config, NULL);992 993 PXOPT_LOOKUP_S64(det_id, config->args, "-add_id", true, false);994 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false);995 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);996 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);997 998 FILE *f = fopen (outfile, "w");999 if (f == NULL) {1000 psError(PS_ERR_UNKNOWN, false, "failed to open output file");1001 return false;1002 }1003 1004 psMetadata *where = psMetadataAlloc();1005 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "==");1006 1007 ExportTable tables [] = {1008 {"addRun", "addtool_export_run.sql"},1009 {"addProcessedExp", "addtool_export_processed_exp.sql"},1010 };1011 1012 for (int i=0; i < numExportTables; i++) {1013 psString query = pxDataGet(tables[i].sqlFilename);1014 if (!query) {1015 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1016 return false;1017 }1018 1019 if (where && psListLength(where->list)) {1020 psString whereClause = psDBGenerateWhereSQL(where, NULL);1021 psStringAppend(&query, " %s", whereClause);1022 psFree(whereClause);1023 }1024 1025 // treat limit == 0 as "no limit"1026 if (limit) {1027 psString limitString = psDBGenerateLimitSQL(limit);1028 psStringAppend(&query, " %s", limitString);1029 psFree(limitString);1030 }1031 1032 if (!p_psDBRunQuery(config->dbh, query)) {1033 psError(PS_ERR_UNKNOWN, false, "database error");1034 psFree(query);1035 return false;1036 }1037 psFree(query);1038 1039 psArray *output = p_psDBFetchResult(config->dbh);1040 if (!output) {1041 psError(PS_ERR_UNKNOWN, false, "database error");1042 return false;1043 }1044 if (!psArrayLength(output)) {1045 psError(PS_ERR_UNKNOWN, true, "no rows found");1046 psFree(output);1047 return false;1048 }1049 1050 if (clean) {1051 if (!strcmp(tables[i].tableName, "addRun")) {1052 if (!pxSetStateCleaned("addRun", "state", output)) {1053 psFree(output);1054 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName);1055 return false;1056 }1057 }1058 }1059 1060 // we must write the export table in non-simple (true) format1061 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {1062 psError(PS_ERR_UNKNOWN, false, "failed to print array");1063 psFree(output);1064 return false;1065 }1066 psFree(output);1067 }1068 1069 fclose (f);1070 1071 return true;1072 }1073 1074 bool importrunMode(pxConfig *config)1075 {1076 unsigned int nFail;1077 1078 PS_ASSERT_PTR_NON_NULL(config, NULL);1079 1080 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false);1081 1082 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false);1083 1084 fprintf (stdout, "---- input ----\n");1085 psMetadataPrint (stderr, input, 1);1086 1087 psMetadataItem *item = psMetadataLookup (input, "addRun");1088 psAssert (item, "entry not in input?");1089 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");1090 1091 psMetadataItem *entry = psListGet (item->data.list, 0);1092 assert (entry);1093 assert (entry->type == PS_DATA_METADATA);1094 addRunRow *addRun = addRunObjectFromMetadata (entry->data.md);1095 addRunInsertObject (config->dbh, addRun);1096 1097 // fprintf (stdout, "---- add run ----\n");1098 // psMetadataPrint (stderr, entry->data.md, 1);1099 1100 item = psMetadataLookup (input, "addProcessedExp");1101 psAssert (item, "entry not in input?");1102 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");1103 1104 for (int i = 0; i < item->data.list->n; i++) {1105 psMetadataItem *entry = psListGet (item->data.list, i);1106 assert (entry);1107 assert (entry->type == PS_DATA_METADATA);1108 addProcessedExpRow *addProcessedExp = addProcessedExpObjectFromMetadata (entry->data.md);1109 addProcessedExpInsertObject (config->dbh, addProcessedExp);1110 1111 // fprintf (stdout, "---- row %d ----\n", i);1112 // psMetadataPrint (stderr, entry->data.md, 1);1113 }1114 1115 return true;1116 } -
branches/eam_branches/20090820/ippTools/src/addtoolConfig.c
r25766 r25870 48 48 49 49 // -definebyquery 50 // XXX need to allow multiple chip_ids51 // XXX need to allow multiple exp_ids52 50 psMetadata *definebyqueryArgs = psMetadataAlloc(); 51 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 53 52 pxcamSetSearchArgs(definebyqueryArgs); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by c hipRun label", NULL);55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by c hipRun reduction class", NULL);53 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 56 55 57 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 59 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 60 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dvodb", 0, "define DVO db", NULL); 60 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-image_only", 0, "addstar image metadata but not detections", false); 61 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 62 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 63 64 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 65 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 66 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 61 67 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 62 68 63 69 // -updaterun 64 // XXX need to allow multiple add_ids65 // XXX need to allow multiple chip_ids66 // XXX need to allow multiple exp_ids67 70 psMetadata *updaterunArgs = psMetadataAlloc(); 71 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 72 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 68 73 pxcamSetSearchArgs(updaterunArgs); 69 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 71 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by camRun state", NULL); 72 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 73 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 74 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 76 74 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by addRun label", NULL); 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by addRun state", NULL); 76 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by addRun reduction class", NULL); 77 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 78 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 79 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 80 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 81 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 82 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 77 83 // -pendingexp 78 84 psMetadata *pendingexpArgs = psMetadataAlloc(); 79 pxcamSetSearchArgs(pendingexpArgs);80 85 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 81 86 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 82 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL); 83 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 87 pxcamSetSearchArgs(pendingexpArgs); 88 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL); 89 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction", 0, "search by addRun reduction class", NULL); 84 90 psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 85 91 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 86 87 // XXX is this used? psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, "search by class", NULL);88 92 89 93 // -addprocessedexp 90 94 psMetadata *addprocessedexpArgs = psMetadataAlloc(); 91 95 psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "define addtool ID (required)", 0); 96 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 97 psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-dtime_addstar", 0, "define elapsed time for DVO insertion (seconds)", NAN); 98 psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 92 99 93 psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-dtime_addstar", 0, "define elapsed time for DVO insertion (seconds)", NAN);94 psMetadataAddS32(addprocessedexpArgs, PS_LIST_TAIL, "-n_stars", 0, "define number of stars", 0);95 96 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL);97 psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-magicked", 0, "set magicked", 0);98 100 // -processedexp 99 101 psMetadata *processedexpArgs = psMetadataAlloc(); 102 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 103 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 100 104 pxcamSetSearchArgs(processedexpArgs); 101 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0);102 105 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL); 103 106 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by addRun reduction class", NULL); 104 107 105 108 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 109 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 110 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0, "only return imfiles with a fault status set", false); 106 111 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-all", 0, "list everything without restriction", false); 107 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);108 /* psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0, "only return imfiles with a fault status set", false); */109 112 110 113 // -revertprocessedexp 111 // XXX need to allow multiple add_ids112 // XXX need to allow multiple chip_ids113 // XXX need to allow multiple exp_ids114 114 psMetadata *revertprocessedexpArgs = psMetadataAlloc(); 115 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 116 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 115 117 pxcamSetSearchArgs(revertprocessedexpArgs); 116 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0);117 118 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL); 118 119 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by addRun reduction class", NULL); … … 121 122 122 123 // -updateprocessedexp 123 // XXX allow full search options?124 124 psMetadata *updateprocessedexpArgs = psMetadataAlloc(); 125 125 psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by addtool ID", 0); 126 126 psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0); 127 psMetadataAddS16(updateprocessedexpArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 127 128 128 129 // -block … … 137 138 psMetadata *unblockArgs = psMetadataAlloc(); 138 139 psMetadataAddStr(unblockArgs, PS_LIST_TAIL, "-label", 0, "name of a label to unmask (required)", NULL); 139 140 // -pendingcleanuprun141 // XXX allow full search options?142 psMetadata *pendingcleanuprunArgs = psMetadataAlloc();143 psMetadataAddStr(pendingcleanuprunArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);144 psMetadataAddBool(pendingcleanuprunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);145 psMetadataAddU64(pendingcleanuprunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);146 147 // -pendingcleanupexp148 // XXX allow full search options?149 psMetadata *pendingcleanupexpArgs = psMetadataAlloc();150 psMetadataAddStr(pendingcleanupexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);151 psMetadataAddS64(pendingcleanupexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by addstar ID", 0);152 psMetadataAddBool(pendingcleanupexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);153 psMetadataAddU64(pendingcleanupexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);154 155 // -donecleanup156 psMetadata *donecleanupArgs = psMetadataAlloc();157 psMetadataAddStr(donecleanupArgs, PS_LIST_TAIL, "-label", 0, "list blocks for specified label", NULL);158 psMetadataAddBool(donecleanupArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);159 psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);160 161 // -exportrun162 psMetadata *exportrunArgs = psMetadataAlloc();163 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-add_id", 0, "export this addstar ID (required)", 0);164 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL);165 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);166 psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean", 0, "export tables as cleaned", false);167 168 // -importrun169 psMetadata *importrunArgs = psMetadataAlloc();170 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL);171 172 140 173 141 psMetadata *argSets = psMetadataAlloc(); … … 184 152 PXOPT_ADD_MODE("-masked", "show blocked labels", ADDTOOL_MODE_MASKED, maskedArgs); 185 153 PXOPT_ADD_MODE("-unblock", "remove a label block", ADDTOOL_MODE_UNBLOCK, unblockArgs); 186 PXOPT_ADD_MODE("-pendingcleanuprun", "show runs that need to be cleaned up", ADDTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunArgs);187 PXOPT_ADD_MODE("-pendingcleanupexp", "show exps for cleanup runs", ADDTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpArgs);188 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", ADDTOOL_MODE_DONECLEANUP, donecleanupArgs);189 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", ADDTOOL_MODE_EXPORTRUN, exportrunArgs);190 PXOPT_ADD_MODE("-importrun", "import run from metadata file", ADDTOOL_MODE_IMPORTRUN, importrunArgs);191 154 192 155 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/eam_branches/20090820/ippTools/src/camtool.c
r25766 r25870 121 121 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 122 122 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 123 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 124 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 123 125 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 124 126 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); … … 126 128 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 127 129 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 130 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 128 131 129 132 // find the exp_id of all the exposures that we want to queue up. … … 212 215 workdir ? workdir : row->workdir, 213 216 label ? label : row->label, 217 data_group ? data_group: row->data_group, 218 dist_group ? dist_group: row->dist_group, 214 219 reduction ? reduction : row->reduction, 215 220 expgroup ? expgroup : row->expgroup, 216 221 dvodb ? dvodb : row->dvodb, 217 222 tess_id ? tess_id : row->tess_id, 218 end_stage ? end_stage : row->end_stage 223 end_stage ? end_stage : row->end_stage, 224 note 219 225 )) { 220 226 if (!psDBRollback(config->dbh)) { … … 251 257 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 252 258 253 if (!psListLength(where->list) 254 && !psMetadataLookupBool(NULL, config->args, "-all")) { 259 if (!psListLength(where->list)) { 255 260 psFree(where); 256 261 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 257 262 return false; 258 263 } 259 260 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 261 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 262 263 if ((!state) && (!label)) { 264 psError(PXTOOLS_ERR_DATA, false, "parameters are required"); 265 psFree(where); 266 return false; 267 } 268 269 if (state) { 270 // set camRun.state to state 271 if (!pxcamRunSetStateByQuery(config, where, state)) { 272 psFree(where); 273 return false; 274 } 275 } 276 277 if (label) { 278 // set camRun.label to label 279 if (!pxcamRunSetLabelByQuery(config, where, label)) { 280 psFree(where); 281 return false; 282 } 283 } 284 264 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 265 266 // pxUpdateRun gets parameters from config->args and updates 267 bool result = pxUpdateRun(config, where, &query, "camRun", true); 268 if (!result) { 269 psError(PXTOOLS_ERR_DATA, false, "pxUpdateRun failed"); 270 } 271 272 psFree(query); 285 273 psFree(where); 286 274 287 return true;275 return result; 288 276 } 289 277 … … 642 630 pendingRow->workdir, 643 631 pendingRow->label, 632 pendingRow->data_group, 633 pendingRow->dist_group, 644 634 pendingRow->reduction, 645 635 pendingRow->expgroup, 646 636 pendingRow->dvodb, 647 637 pendingRow->tess_id, 648 pendingRow->end_stage 638 pendingRow->end_stage, 639 NULL // note does not propagate 649 640 )) { 650 641 // rollback … … 656 647 return false; 657 648 } 658 659 /* if (!pxaddQueueByCamID(config, */660 /* pendingRow->cam_id, */661 /* pendingRow->workdir, */662 /* pendingRow->label, */663 /* pendingRow->reduction, */664 /* pendingRow->dvodb */665 /* )) { */666 /* // rollback */667 /* if (!psDBRollback(config->dbh)) { */668 /* psError(PS_ERR_UNKNOWN, false, "database error"); */669 /* } */670 /* psError(PS_ERR_UNKNOWN, false, "failed to queue new addRun"); */671 /* psFree(pendingRow); */672 /* return false; */673 /* } */674 649 675 650 psFree(pendingRow); … … 1172 1147 } 1173 1148 1149 if (!pxExportVersion(config, f)) { 1150 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1151 return false; 1152 } 1153 1174 1154 psMetadata *where = psMetadataAlloc(); 1175 1155 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); … … 1252 1232 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1253 1233 1254 fprintf (stdout, "---- input ----\n"); 1234 #ifdef notdef 1235 fprintf (stderr, "---- input ----\n"); 1255 1236 psMetadataPrint (stderr, input, 1); 1237 #endif 1238 1239 if (!pxCheckImportVersion(config, input)) { 1240 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1241 return false; 1242 } 1256 1243 1257 1244 psMetadataItem *item = psMetadataLookup (input, "camRun"); -
branches/eam_branches/20090820/ippTools/src/camtoolConfig.c
r24681 r25870 62 62 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_tess_id", 0, "define tess ID", NULL); 63 63 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_end_stage", 0, "define end stage", NULL); 64 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 64 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 65 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 66 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 65 67 66 68 // -updaterun … … 77 79 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 78 80 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 79 81 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 82 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 83 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 80 84 // -pendingexp 81 85 psMetadata *pendingexpArgs = psMetadataAlloc(); -
branches/eam_branches/20090820/ippTools/src/chiptool.c
r25766 r25870 57 57 static bool exportrunMode(pxConfig *config); 58 58 static bool importrunMode(pxConfig *config); 59 static bool runstateMode(pxConfig *config); 59 60 60 61 # define MODECASE(caseName, func) \ … … 97 98 MODECASE(CHIPTOOL_MODE_EXPORTRUN, exportrunMode); 98 99 MODECASE(CHIPTOOL_MODE_IMPORTRUN, importrunMode); 100 MODECASE(CHIPTOOL_MODE_RUNSTATE, runstateMode); 99 101 default: 100 102 psAbort("invalid option (this should not happen)"); … … 144 146 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 145 147 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 148 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 149 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 150 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 146 151 147 152 // default … … 263 268 workdir ? workdir : raw_workdir, 264 269 label ? label : raw_label, 270 data_group ? data_group : (label ? label : raw_label), 271 dist_group, 265 272 reduction ? reduction : raw_reduction, 266 273 // expgroup ? expgroup : raw_expgroup, … … 269 276 dvodb ? dvodb : raw_dvodb, 270 277 tess_id ? tess_id : raw_tess_id, 271 end_stage ? end_stage : raw_end_stage 278 end_stage ? end_stage : raw_end_stage, 279 note 272 280 )) { 273 281 if (!psDBRollback(config->dbh)) { … … 301 309 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 302 310 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 303 304 if (!psListLength(where->list) && 305 !psMetadataLookupBool(NULL, config->args, "-all")) { 311 PXOPT_COPY_STR(config->args, where, "-data_group", "chipRun.data_group", "=="); 312 PXOPT_COPY_STR(config->args, where, "-dist_group", "chipRun.dist_group", "=="); 313 314 if (!psListLength(where->list)) { 306 315 psFree(where); 307 where = NULL;308 316 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 309 317 return false; 310 318 } 311 312 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 313 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 314 315 if ((!state) && (!label)) { 316 psError(PXTOOLS_ERR_DATA, false, "parameters are required"); 317 psFree(where); 318 return false; 319 } 320 321 if (state) { 322 // set chipRun.state to state 323 if (!pxchipRunSetStateByQuery(config, where, state)) { 324 psFree(where); 325 return false; 326 } 327 } 328 329 if (label) { 330 // set chipRun.label to label 331 if (!pxchipRunSetLabelByQuery(config, where, label)) { 332 psFree(where); 333 return false; 334 } 335 } 336 319 psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id)"); 320 321 // pxUpdateRun gets parameters from config->args and updates 322 bool result = pxUpdateRun(config, where, &query, "chipRun", true); 323 if (!result) { 324 psError(PXTOOLS_ERR_DATA, false, "pxUpdateRun failed"); 325 } 326 327 psFree(query); 337 328 psFree(where); 338 329 339 return true;330 return result; 340 331 } 341 332 … … 605 596 PXOPT_COPY_S64(config->args, where, "-magicked", "chipProcessedImfile.magicked", "=="); 606 597 607 PXOPT_LOOKUP_U64(magicked, config->args, "-magicked", false, false); 608 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false); 609 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false); 610 611 if (!psListLength(where->list) && 612 !psMetadataLookupBool(NULL, config->args, "-all")) { 613 psFree(where); 614 psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required"); 598 psString where2 = NULL; 599 pxmagicAddWhere(config, &where2, "chipProcessedImfile"); 600 // add cuts on ra and decl if supplied 601 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 602 psError(PXTOOLS_ERR_DATA, false, "pxSpaceAddWhere failed"); 615 603 return false; 616 604 } … … 622 610 } 623 611 624 if ( where &&psListLength(where->list)) {612 if (psListLength(where->list)) { 625 613 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 626 614 psStringAppend(&query, " WHERE %s", whereClause); 627 615 psFree(whereClause); 616 } else if (psMetadataLookupBool(NULL, config->args, "-all") || (faulted || where2)) { 617 psStringAppend(&query, " WHERE chipRun.chip_id IS NOT NULL %s", where2 ? where2 : ""); 618 } else { 619 psFree(where); 620 psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required"); 621 return false; 628 622 } 629 623 psFree(where); … … 635 629 // don't list faulted rows 636 630 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0"); 637 }638 if (not_destreaked) {639 if (destreaked) {640 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense");641 return false;642 }643 if (magicked) {644 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense");645 return false;646 }647 psStringAppend(&query, " AND chipProcessedImfile.magicked = 0");648 }649 if (destreaked) {650 psStringAppend(&query, " AND chipProcessedImfile.magicked != 0");651 631 } 652 632 … … 739 719 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 740 720 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 741 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 742 743 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) { 721 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, NULL); 722 723 if (!state) { 724 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 725 726 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) { 744 727 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 745 728 return false; 746 } 747 psFree(where); 748 729 } 730 psFree(where); 731 } 732 else { 733 if (!pxchipProcessedImfileSetStateByQuery(config,where,state)) { 734 psError(PS_ERR_UNKNOWN, false, "failed to set chipProcessedImfile state"); 735 return(false); 736 } 737 } 738 739 749 740 return true; 750 741 } … … 1114 1105 1115 1106 psMetadata *where = psMetadataAlloc(); 1107 pxchipGetSearchArgs (config, where); // chipRun, chipProcessedImfile, rawExp 1108 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1109 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 1116 1110 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1117 1111 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); … … 1253 1247 chipRun->workdir, 1254 1248 chipRun->label, 1249 chipRun->data_group, 1250 chipRun->dist_group, 1255 1251 chipRun->reduction, 1256 1252 chipRun->expgroup, 1257 1253 chipRun->dvodb, 1258 1254 chipRun->tess_id, 1259 chipRun->end_stage 1255 chipRun->end_stage, 1256 NULL // note does not propagate 1260 1257 )) { 1261 1258 if (!psDBRollback(config->dbh)) { … … 1380 1377 } 1381 1378 1379 if (!pxExportVersion(config, f)) { 1380 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1381 return false; 1382 } 1383 1382 1384 psMetadata *where = psMetadataAlloc(); 1383 1385 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); … … 1471 1473 psVector *identifiers = psVectorAllocEmpty(16, PS_TYPE_U64); // Identifiers inserted 1472 1474 1475 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator 1476 1477 if (!pxCheckImportVersion(config, input)) { 1478 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1479 return false; 1480 } 1481 // first item is the dbversion, skip it 1482 psMetadataItem *dbversion = psMetadataGetAndIncrement(iter); 1483 (void) dbversion; 1484 1473 1485 if (!psDBTransaction(config->dbh)) { 1474 1486 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1476 1488 } 1477 1489 1478 psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL); // Iterator1479 1490 psMetadataItem *item; // Item from iteration 1480 1491 while ((item = psMetadataGetAndIncrement(iter))) { … … 1505 1516 return true; 1506 1517 } 1518 1519 static bool runstateMode(pxConfig *config) 1520 { 1521 PS_ASSERT_PTR_NON_NULL(config, false); 1522 1523 psMetadata *where = psMetadataAlloc(); 1524 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1525 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1526 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1527 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "LIKE"); 1528 1529 // PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1530 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 1531 1532 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1533 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1534 1535 psString query = pxDataGet("chiptool_runstate.sql"); 1536 if (!query) { 1537 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1538 return false; 1539 } 1540 1541 if (psListLength(where->list)) { 1542 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1543 psStringAppend(&query, " WHERE %s", whereClause); 1544 psFree(whereClause); 1545 } else { 1546 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 1547 return false; 1548 } 1549 psFree(where); 1550 1551 // treat limit == 0 as "no limit" 1552 if (limit) { 1553 psString limitString = psDBGenerateLimitSQL(limit); 1554 psStringAppend(&query, " %s", limitString); 1555 psFree(limitString); 1556 } 1557 1558 if (!p_psDBRunQuery(config->dbh, query)) { 1559 psError(PS_ERR_UNKNOWN, false, "database error"); 1560 psFree(query); 1561 return false; 1562 } 1563 psFree(query); 1564 1565 psArray *output = p_psDBFetchResult(config->dbh); 1566 if (!output) { 1567 psErrorCode err = psErrorCodeLast(); 1568 switch (err) { 1569 case PS_ERR_DB_CLIENT: 1570 psError(PXTOOLS_ERR_SYS, false, "database error"); 1571 case PS_ERR_DB_SERVER: 1572 psError(PXTOOLS_ERR_PROG, false, "database error"); 1573 default: 1574 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1575 } 1576 1577 return false; 1578 } 1579 if (!psArrayLength(output)) { 1580 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1581 psFree(output); 1582 return true; 1583 } 1584 1585 if (psArrayLength(output)) { 1586 // negative simple so the default is true 1587 if (!ippdbPrintMetadatas(stdout, output, "chipRunState", !simple)) { 1588 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1589 psFree(output); 1590 return false; 1591 } 1592 } 1593 1594 psFree(output); 1595 1596 return true; 1597 } -
branches/eam_branches/20090820/ippTools/src/chiptool.h
r25766 r25870 47 47 CHIPTOOL_MODE_TOSCRUBBEDIMFILE, 48 48 CHIPTOOL_MODE_EXPORTRUN, 49 CHIPTOOL_MODE_IMPORTRUN 49 CHIPTOOL_MODE_IMPORTRUN, 50 CHIPTOOL_MODE_RUNSTATE 50 51 } chiptoolMode; 51 52 -
branches/eam_branches/20090820/ippTools/src/chiptoolConfig.c
r25766 r25870 58 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_tess_id", 0, "define tessellation identifier", NULL); 59 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_end_stage", 0, "define end stage", NULL); 60 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 61 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define distribution group", NULL); 62 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 60 63 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 61 64 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 62 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false);63 65 64 66 // -updaterun … … 67 69 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 68 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 69 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 71 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 72 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-data_group", 0, "search by data_group", NULL); 73 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-dist_group", 0, "search by dist_group", NULL); 70 74 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 71 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 72 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 76 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "set data group", NULL); 77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "set dist group", NULL); 78 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "set note", NULL); 73 79 74 80 // -pendingimfile … … 158 164 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 159 165 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by chipRun label (LIKE comparison)", NULL); 160 161 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-destreaked", 0, "search for destreaked images", false); 162 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-not_destreaked", 0, "search for images that have not been destreaked", false); 163 psMetadataAddS64(processedimfileArgs, PS_LIST_TAIL, "-magicked", 0, "search by magicked value", 0); 166 pxmagicAddArguments(processedimfileArgs); 167 164 168 psMetadataAddU64(processedimfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 165 169 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-all", 0, "list everything without search terms", false); 166 170 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-faulted", 0, "only return imfiles with a fault status set", false); 167 171 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 172 173 pxspaceAddArguments(processedimfileArgs); 168 174 169 175 // -revertprocessedimfile … … 182 188 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 183 189 psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code (required)", 0); 184 190 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 185 191 // -block 186 192 psMetadata *blockArgs = psMetadataAlloc(); … … 229 235 psMetadataAddU64(runArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 230 236 psMetadataAddStr(runArgs, PS_LIST_TAIL, "-state", 0, "search by state (required)", NULL); 237 pxchipSetSearchArgs(runArgs); 238 psMetadataAddS64(runArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 239 psMetadataAddStr(runArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 231 240 232 241 // -advanceexp … … 268 277 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 269 278 279 // -runstate 280 psMetadata *runstateArgs = psMetadataAlloc(); 281 psMetadataAddS64(runstateArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 282 psMetadataAddS64(runstateArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure tag", 0); 283 psMetadataAddStr(runstateArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exposure tag", 0); 284 psMetadataAddStr(runstateArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by warpRun label", NULL); 285 psMetadataAddBool(runstateArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not necessary for result", false); 286 287 psMetadataAddU64(runstateArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 288 psMetadataAddBool(runstateArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 289 270 290 psMetadata *argSets = psMetadataAlloc(); 271 291 psMetadata *modes = psMetadataAlloc(); … … 278 298 PXOPT_ADD_MODE("-updateprocessedimfile","change procesed imfile properties", CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,updateprocessedimfileArgs); 279 299 PXOPT_ADD_MODE("-revertprocessedimfile","undo a processed imfile", CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,revertprocessedimfileArgs); 300 PXOPT_ADD_MODE("-runstate", "list the states of chip run", CHIPTOOL_MODE_RUNSTATE, runstateArgs); 280 301 PXOPT_ADD_MODE("-advanceexp", "advance completed exposures", CHIPTOOL_MODE_ADVANCEEXP, advanceexpArgs); 281 302 PXOPT_ADD_MODE("-block", "set a label block", CHIPTOOL_MODE_BLOCK, blockArgs); -
branches/eam_branches/20090820/ippTools/src/difftool.c
r25766 r25870 51 51 52 52 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked); 53 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state); 54 static bool tocleanedskyfileMode(pxConfig *config); 55 static bool topurgedskyfileMode(pxConfig *config); 56 static bool toscrubbedskyfileMode(pxConfig *config); 57 58 53 59 54 60 # define MODECASE(caseName, func) \ … … 88 94 MODECASE(DIFFTOOL_MODE_EXPORTRUN, exportrunMode); 89 95 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 96 MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileMode); 97 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode); 98 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 99 90 100 default: 91 101 psAbort("invalid option (this should not happen)"); … … 115 125 116 126 // required options 117 PXOPT_LOOKUP_STR(workdir, config->args, "- workdir", true, false);127 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 118 128 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 119 129 PXOPT_LOOKUP_BOOL(bothways, config->args, "-bothways", false); 120 130 PXOPT_LOOKUP_BOOL(exposure, config->args, "-exposure", false); 121 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 122 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 131 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 132 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 133 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 134 PXOPT_LOOKUP_STR(reduction, config->args, "-rset_eduction", false, false); 135 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 123 136 124 137 // default … … 131 144 workdir, 132 145 label, 146 data_group ? data_group : label, 147 dist_group, 133 148 reduction, 134 149 NULL, // dvodb … … 137 152 bothways, 138 153 exposure, 139 false 154 false, 155 note 140 156 ); 141 157 if (!run) { … … 168 184 PS_ASSERT_PTR_NON_NULL(config, false); 169 185 186 psMetadata *where = psMetadataAlloc(); 187 188 PXOPT_COPY_S64(config->args, where, "-diff_id", "stack_id", "=="); 189 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 190 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 191 if (!psListLength(where->list)) { 192 psFree(where); 193 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 194 return false; 195 } 196 197 psString query = psStringCopy("UPDATE diffRun"); 198 199 // pxUpdateRun gets parameters from config->args and updates 200 bool result = pxUpdateRun(config, where, &query, "diffRun", true); 201 202 psFree(query); 203 psFree(where); 204 205 return result; 206 207 #ifdef notdef 170 208 // required options 171 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);209 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false); 172 210 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 173 174 if (state) { 211 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 212 213 // Copy of my hacky work around from stacktool.c 214 if ((state)&&(diff_id)) { 175 215 // set detRun.state to state 176 216 return setdiffRunState(config, diff_id, state, false); 177 217 } 178 218 179 return true; 219 if ((state)&&(label)) { 220 return setdiffRunStateByLabel(config, label, state); 221 } 222 223 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 224 225 return false; 226 #endif 180 227 } 181 228 … … 692 739 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 693 740 694 PXOPT_LOOKUP_U64(magicked, config->args, "-magicked", false, false); 695 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);696 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false);697 741 742 psString where2 = NULL; 743 pxmagicAddWhere(config, &where2, "diffSkyfile"); 744 pxspaceAddWhere(config, &where2, template ? "rawTemplate" : "rawInput"); 698 745 psString query = pxDataGet("difftool_skyfile.sql"); 699 746 if (!query) { … … 706 753 psStringAppend(&query, " WHERE %s", whereClause); 707 754 psFree(whereClause); 755 } else if (where2) { 756 psStringAppend(&query, " WHERE diffRun.diff_id is not null %s", where2); 708 757 } else if (!all) { 709 758 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 759 return false; 710 760 } 711 761 psFree(where); 712 713 if (not_destreaked) {714 if (destreaked) {715 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense");716 return false;717 }718 if (magicked) {719 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense");720 return false;721 }722 psStringAppend(&query, " AND diffSkyfile.magicked = 0");723 }724 if (destreaked) {725 psStringAppend(&query, " AND diffSkyfile.magicked != 0");726 }727 728 762 729 763 // treat limit == 0 as "no limit" … … 878 912 } 879 913 880 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 881 882 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 914 if (magicked) { 915 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 916 917 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 883 918 psError(PS_ERR_UNKNOWN, false, 884 919 "failed to change state for diff_id %"PRId64, diff_id); 885 920 return false; 886 } 887 921 } 922 } 923 else { 924 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 925 926 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 927 psError(PS_ERR_UNKNOWN, false, 928 "failed to change state for diff_id %"PRId64, diff_id); 929 return false; 930 } 931 } 932 888 933 return true; 889 934 } 935 936 937 #ifdef notdef 938 static bool setdiffRunStateByLabel(pxConfig *config, const char *label, const char *state) { 939 PS_ASSERT_PTR_NON_NULL(state,false); 940 941 // check that state is a valid string value 942 if (!pxIsValidState(state)) { 943 psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state); 944 return false; 945 } 946 947 char *query = "UPDATE diffRun SET state = '%s' WHERE label = '%s'"; 948 if (!p_psDBRunQueryF(config->dbh,query,state,label)) { 949 psError(PS_ERR_UNKNOWN, false, 950 "failed to change state for label %s", label); 951 return(false); 952 } 953 954 return true; 955 } 956 #endif 890 957 891 958 // Generate a single populated run … … 895 962 const char *tess_id, // Tessellation identifier 896 963 const char *label, // label 964 const char *data_group, // data_group 965 const char *dist_group, // dist_group 897 966 const char *reduction, // reduction 967 const char *note, // note 898 968 psS64 input_warp_id, // Warp identifier for input image, PS_MAX_S64 for none 899 969 psS64 input_stack_id, // Stack identifier for input image, PS_MAX_S64 for none … … 926 996 workdir, 927 997 label, 998 data_group ? data_group : label, 999 dist_group, 928 1000 reduction, 929 1001 NULL, // dvodb … … 932 1004 false, 933 1005 false, 934 0 // magicked 1006 0, // magicked 1007 note 935 1008 ); 936 1009 … … 1006 1079 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); // required options 1007 1080 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 1081 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 1082 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 1008 1083 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 1009 1084 PXOPT_LOOKUP_S64(template_warp_id, config->args, "-template_warp_id", false, false); … … 1012 1087 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 1013 1088 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1089 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 1014 1090 1015 1091 if (template_stack_id && template_warp_id) { … … 1035 1111 psArray *list = psArrayAllocEmpty(16); // List of runs, to print 1036 1112 1037 if (!populatedrun(list, workdir, skycell_id, tess_id, label, reduction,1113 if (!populatedrun(list, workdir, skycell_id, tess_id, label, data_group ? data_group : label, dist_group, reduction, note, 1038 1114 input_warp_id ? input_warp_id : PS_MAX_S64, 1039 1115 input_stack_id ? input_stack_id : PS_MAX_S64, … … 1074 1150 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); 1075 1151 1076 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1077 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1078 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1079 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1152 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); // required option 1153 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); // option 1154 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); // option 1155 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 1156 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 1157 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 1158 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 1159 1080 1160 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1081 1161 PXOPT_LOOKUP_BOOL(newTemplates, config->args, "-new-templates", false); … … 1313 1393 workdir, 1314 1394 label, 1395 data_group ? data_group : label, 1396 dist_group, 1315 1397 reduction, 1316 1398 NULL, // dvodb … … 1319 1401 false, // bothways 1320 1402 true, // exposure 1321 0 // magicked 1403 0, // magicked 1404 note 1322 1405 ); 1323 1406 … … 1388 1471 } 1389 1472 1390 if ( !diffRunPrintObjects(stdout, list, !simple)) {1473 if (numGood && !diffRunPrintObjects(stdout, list, !simple)) { 1391 1474 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 1392 1475 psFree(list); … … 1469 1552 1470 1553 // Settings to apply to defined run 1471 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1472 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1473 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1474 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1554 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); // required options 1555 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); // option 1556 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); // option 1557 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); // option 1558 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); // option 1559 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); // option 1560 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 1561 1475 1562 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1476 1563 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); … … 1656 1743 } 1657 1744 1658 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered,1659 tess_id, true, true, false ); // Run to insert1745 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, data_group ? data_group : label, dist_group, reduction, NULL, registered, 1746 tess_id, true, true, false, note); // Run to insert 1660 1747 if (!diffRunInsertObject(config->dbh, run)) { 1661 1748 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1738 1825 1739 1826 psMetadata *where = psMetadataAlloc(); 1740 pxAddLabelSearchArgs (config, where, "-label", " diffRun.label", "==");1827 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1741 1828 1742 1829 psString query = pxDataGet("difftool_pendingcleanuprun.sql"); … … 1760 1847 } 1761 1848 1849 // fprintf(stderr,"%s",query); 1762 1850 if (!p_psDBRunQuery(config->dbh, query)) { 1763 1851 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1931 2019 1932 2020 return true; 2021 } 2022 2023 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state) { 2024 PS_ASSERT_PTR_NON_NULL(config, false); 2025 2026 // diff_id, skycell_id are required 2027 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 2028 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 2029 2030 psString query = pxDataGet("difftool_change_skyfile_data_state.sql"); 2031 2032 if (!psDBTransaction(config->dbh)) { 2033 psError(PS_ERR_UNKNOWN, false, "database error"); 2034 return(false); 2035 } 2036 2037 // Uses the unconstrained (diffRun.state [NEED NOT EQUAL] run_state) version from warptool.c 2038 2039 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, skycell_id)) { 2040 psError(PS_ERR_UNKNOWN, false, "database error"); 2041 // rollback 2042 if (!psDBRollback(config->dbh)) { 2043 psError(PS_ERR_UNKNOWN, false, "database error"); 2044 } 2045 psError(PS_ERR_UNKNOWN, false, "database error"); 2046 return(false); 2047 } 2048 psFree(query); 2049 2050 query = pxDataGet("difftool_change_run_state.sql"); 2051 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, data_state)) { 2052 // rollback 2053 if (!psDBRollback(config->dbh)) { 2054 psError(PS_ERR_UNKNOWN, false, "database error"); 2055 } 2056 psError(PS_ERR_UNKNOWN, false, "database error"); 2057 return(false); 2058 } 2059 2060 if (!psDBCommit(config->dbh)) { 2061 psError(PS_ERR_UNKNOWN, false, "database error"); 2062 return(false); 2063 } 2064 2065 return(true); 2066 } 2067 2068 static bool tocleanedskyfileMode(pxConfig *config) { 2069 return change_skyfile_data_state(config, "cleaned","goto_cleaned"); 2070 } 2071 static bool topurgedskyfileMode(pxConfig *config) { 2072 return change_skyfile_data_state(config, "purged", "goto_purged"); 2073 } 2074 static bool toscrubbedskyfileMode(pxConfig *config) { 2075 return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed"); 1933 2076 } 1934 2077 … … 1956 2099 } 1957 2100 2101 if (!pxExportVersion(config, f)) { 2102 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 2103 return false; 2104 } 1958 2105 psMetadata *where = psMetadataAlloc(); 1959 2106 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); … … 2047 2194 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 2048 2195 2049 fprintf (stdout, "---- input ----\n"); 2196 #ifdef notdef 2197 fprintf (stderr, "---- input ----\n"); 2050 2198 psMetadataPrint (stderr, input, 1); 2051 2199 #endif 2200 2201 if (!pxCheckImportVersion(config, input)) { 2202 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 2203 return false; 2204 } 2052 2205 psMetadataItem *item = psMetadataLookup (input, "diffRun"); 2053 2206 psAssert (item, "entry not in input?"); -
branches/eam_branches/20090820/ippTools/src/difftool.h
r25766 r25870 42 42 DIFFTOOL_MODE_UPDATEDIFFSKYFILE, 43 43 DIFFTOOL_MODE_EXPORTRUN, 44 DIFFTOOL_MODE_IMPORTRUN 44 DIFFTOOL_MODE_IMPORTRUN, 45 DIFFTOOL_MODE_TOCLEANEDSKYFILE, 46 DIFFTOOL_MODE_TOPURGEDSKYFILE, 47 DIFFTOOL_MODE_TOSCRUBBEDSKYFILE 48 45 49 } difftoolMode; 46 50 -
branches/eam_branches/20090820/ippTools/src/difftoolConfig.c
r25766 r25870 47 47 // -definerun 48 48 psMetadata *definerunArgs = psMetadataAlloc(); 49 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "- workdir", 0,"define workdir (required)", NULL);49 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); 50 50 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-tess_id", 0, "define tessellation ID (required)", NULL); 51 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-bothways", 0, "do the subtraction both ways?", false); 52 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-exposure", 0, "subtraction for entire exposure?", false); 53 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 54 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction class", NULL); 55 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 51 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-bothways", 0, "do the subtraction both ways?", false); 52 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-exposure", 0, "subtraction for entire exposure?", false); 53 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 54 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 55 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 56 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 57 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 58 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 56 59 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 57 60 58 61 // -updaterun 59 62 psMetadata *updaterunArgs = psMetadataAlloc(); 60 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-diff_id", 0, "define diff ID (required)", 0); 61 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 63 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-diff_id", 0, "define diff ID", 0); 64 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state", NULL); 65 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "define by label instead of diff ID", 0); 66 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "define new value for label", 0); 67 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "define new state", NULL); 68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 69 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 62 71 63 72 // -addinputskyfile … … 134 143 psMetadataAddTime(diffskyfileArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<=)", NULL); 135 144 psMetadataAddStr(diffskyfileArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 136 psMetadataAddS64(diffskyfileArgs, PS_LIST_TAIL, "-magicked", 0, "search by magicked value", 0);137 psMetadataAddBool(diffskyfileArgs, PS_LIST_TAIL, "-destreaked", 0, "search for destreaked images", false);138 psMetadataAddBool(diffskyfileArgs, PS_LIST_TAIL, "-not_destreaked", 0, "search for images that are not destreaked", false);139 145 psMetadataAddStr(diffskyfileArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by diffRun label (LIKE comparison)", NULL); 140 146 psMetadataAddS16(diffskyfileArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 147 pxmagicAddArguments(diffskyfileArgs); 148 pxspaceAddArguments(diffskyfileArgs); 141 149 142 150 psMetadataAddBool(diffskyfileArgs, PS_LIST_TAIL, "-all", 0, "search without arguments", false); … … 175 183 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-warp_label", 0, "search by warp label", NULL); 176 184 psMetadataAddF32(definewarpstackArgs, PS_LIST_TAIL, "-good_frac", 0, "minimum good fraction of skycell", NAN); 177 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 178 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 179 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction class", NULL); 180 psMetadataAddTime(definewarpstackArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 185 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); 186 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 187 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 188 psMetadataAddTime(definewarpstackArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 189 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 190 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 191 psMetadataAddStr(definewarpstackArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 181 192 psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-new-templates", 0, "also search for diffs with new template", false); 182 193 psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false); … … 198 209 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-template_label", 0, "search by warp label for template", NULL); 199 210 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-good_frac", 0, "minimum good fraction of skycell", NAN); 200 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 201 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 202 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction class", NULL); 203 psMetadataAddTime(definewarpwarpArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 211 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); 212 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 213 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 214 psMetadataAddTime(definewarpwarpArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 215 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 216 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 217 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 204 218 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false); 205 219 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-available", 0, "define new run even if warpRun has some faults", false); … … 259 273 psMetadataAddS16(updatediffskyfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code (required)", 0); 260 274 275 // -tocleanedskyfile 276 psMetadata *tocleanedskyfileArgs = psMetadataAlloc(); 277 psMetadataAddS64(tocleanedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 278 psMetadataAddStr(tocleanedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 279 280 // -topurgedskyfile 281 psMetadata *topurgedskyfileArgs = psMetadataAlloc(); 282 psMetadataAddS64(topurgedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 283 psMetadataAddStr(topurgedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 284 285 // -toscrubbedskyfile 286 psMetadata *toscrubbedskyfileArgs = psMetadataAlloc(); 287 psMetadataAddS64(toscrubbedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 288 psMetadataAddStr(toscrubbedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 289 261 290 // -exportrun 262 291 psMetadata *exportrunArgs = psMetadataAlloc(); … … 296 325 PXOPT_ADD_MODE("-importrun", "import run from metadata file", DIFFTOOL_MODE_IMPORTRUN, importrunArgs); 297 326 327 PXOPT_ADD_MODE("-tocleanedskyfile", "set skyfile as cleaned", DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileArgs); 328 PXOPT_ADD_MODE("-topurgedskyfile", "set skyfile as purged", DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileArgs); 329 PXOPT_ADD_MODE("-toscrubbedskyfile", "set skyfile as scrubbed", DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileArgs); 330 298 331 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { 299 332 psError(PS_ERR_UNKNOWN, true, "option parsing failed"); -
branches/eam_branches/20090820/ippTools/src/disttool.c
r25766 r25870 32 32 33 33 static bool definebyqueryMode(pxConfig *config); 34 static bool definerunMode(pxConfig *config);35 34 static bool updaterunMode(pxConfig *config); 36 35 static bool revertrunMode(pxConfig *config); … … 79 78 switch (config->mode) { 80 79 MODECASE(DISTTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 81 MODECASE(DISTTOOL_MODE_DEFINERUN, definerunMode);82 80 MODECASE(DISTTOOL_MODE_UPDATERUN, updaterunMode); 83 81 MODECASE(DISTTOOL_MODE_REVERTRUN, revertrunMode); … … 123 121 } 124 122 125 static bool definerunMode(pxConfig *config)126 {127 PS_ASSERT_PTR_NON_NULL(config, false);128 129 // required130 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);131 PXOPT_LOOKUP_S64(stage_id, config->args, "-stage_id", true, false);132 PXOPT_LOOKUP_STR(outroot, config->args, "-outroot", true, false);133 PXOPT_LOOKUP_S64(target_id, config->args, "-target_id", true, false);134 135 // optional136 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);137 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false);138 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false);139 140 // TODO: check that stage has an expected value141 // XXX: all of the following concerns will be managed properly by definebyquery142 143 // TODO: should we check that stage_id actually exists for stage144 // in magicdstool we queue off of a magic_id so the stage_id, exp_id, and cam_id get looked up145 // when the run is queued146 147 if (!distRunInsert(config->dbh,148 0, // dist_id149 target_id,150 stage,151 stage_id,152 0,153 set_label,154 outroot,155 clean,156 no_magic,157 "new",158 NULL, // time_stamp159 0 // fault160 )) {161 psError(PS_ERR_UNKNOWN, false, "database error");162 return false;163 }164 165 return true;166 }167 123 168 124 static bool definebyqueryMode(pxConfig *config) … … 178 134 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 179 135 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 136 PXOPT_LOOKUP_STR(set_note, config->args, "-set_note", false, false); 137 180 138 PXOPT_LOOKUP_S64(limit, config->args, "-limit", false, false); 181 139 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 191 149 192 150 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 151 PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", false, false); 193 152 194 153 psString query = NULL; … … 209 168 psStringAppend(&query, " AND (chipRun.label = '%s')", label); 210 169 } 170 if (dist_group) { 171 psStringAppend(&query, " AND (chipRun.dist_group = '%s')", dist_group); 172 } 211 173 } else if (!strcmp(stage, "chip")) { 212 174 magicRunType = "chipRun"; … … 222 184 psStringAppend(&query, " AND (chipRun.label = '%s')", label); 223 185 } 186 if (dist_group) { 187 psStringAppend(&query, " AND (chipRun.dist_group = '%s')", dist_group); 188 } 224 189 } else if (!strcmp(stage, "camera")) { 225 190 magicRunType = "camRun"; // This is used below to set the magicked business … … 235 200 psStringAppend(&query, " AND (camRun.label = '%s')", label); 236 201 } 202 if (dist_group) { 203 psStringAppend(&query, " AND (camRun.dist_group = '%s')", dist_group); 204 } 237 205 } else if (!strcmp(stage, "fake")) { 238 206 magicRunType = "fakeRun"; … … 246 214 if (label) { 247 215 psStringAppend(&query, " AND (fakeRun.label = '%s')", label); 216 } 217 if (dist_group) { 218 psStringAppend(&query, " AND (fakeRun.dist_group = '%s')", dist_group); 248 219 } 249 220 // fake stage doesn't require magic … … 262 233 psStringAppend(&query, " AND (warpRun.label = '%s')", label); 263 234 } 235 if (dist_group) { 236 psStringAppend(&query, " AND (warpRun.dist_group = '%s')", dist_group); 237 } 264 238 265 239 } else if (!strcmp(stage, "diff")) { … … 276 250 psStringAppend(&query, " AND (diffRun.label = '%s')", label); 277 251 } 252 if (dist_group) { 253 psStringAppend(&query, " AND (diffRun.dist_group = '%s')", dist_group); 254 } 278 255 279 256 } else if (!strcmp(stage, "stack")) { … … 288 265 if (label) { 289 266 psStringAppend(&query, " AND (stackRun.label = '%s')", label); 267 } 268 if (dist_group) { 269 psStringAppend(&query, " AND (stackRun.dist_group = '%s')", dist_group); 290 270 } 291 271 // stack stage doesn't require magic … … 371 351 psS64 magic_ds_id = psMetadataLookupS64(NULL, md, "magicked"); 372 352 psS64 target_id = psMetadataLookupS64(NULL, md, "target_id"); 373 psString target_label = psMetadataLookupStr(NULL, md, "label");353 psString stage_label = psMetadataLookupStr(NULL, md, "label"); 374 354 bool clean = psMetadataLookupBool(NULL, md, "clean"); 375 355 … … 381 361 new_label = set_label; 382 362 } else { 383 new_label = target_label;363 new_label = stage_label; 384 364 } 385 365 distRunRow *row = distRunRowAlloc( … … 395 375 "new", 396 376 NULL, // time_stamp 397 0 // fault 377 0, // fault 378 set_note // note does not propagate 398 379 ); 399 380 … … 1239 1220 1240 1221 // required 1241 PXOPT_LOOKUP_STR( label, config->args, "-label", true, false);1222 PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", true, false); 1242 1223 PXOPT_LOOKUP_STR(filter, config->args, "-filter", true, false); 1243 1224 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); … … 1250 1231 distTargetRow *row = distTargetRowAlloc( 1251 1232 0, // target_id 1252 label,1233 dist_group, 1253 1234 filter, 1254 1235 stage, … … 1287 1268 psMetadata *where = psMetadataAlloc(); 1288 1269 PXOPT_COPY_S64(config->args, where, "-target_id", "target_id", "=="); 1289 PXOPT_COPY_STR(config->args, where, "- label", "label", "==");1270 PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "=="); 1290 1271 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 1291 1272 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); … … 1323 1304 psMetadata *where = psMetadataAlloc(); 1324 1305 PXOPT_COPY_S64(config->args, where, "-target_id", "target_id", "=="); 1325 PXOPT_COPY_STR(config->args, where, "- label", "label", "==");1306 PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "LIKE"); 1326 1307 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 1327 1308 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); … … 1518 1499 PXOPT_LOOKUP_S64(target_id, config->args, "-target_id", false, false); 1519 1500 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 1520 PXOPT_LOOKUP_STR( label, config->args, "-label", false, false);1501 PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", false, false); 1521 1502 PXOPT_LOOKUP_STR(filter, config->args, "-filter", false, false); 1522 1503 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); … … 1528 1509 error = true; 1529 1510 } 1530 if (! label) {1531 psError(PS_ERR_UNKNOWN, !error, " labelis required if target_id is not supplied");1511 if (!dist_group) { 1512 psError(PS_ERR_UNKNOWN, !error, "dist_group is required if target_id is not supplied"); 1532 1513 error = true; 1533 1514 } … … 1539 1520 // optional 1540 1521 PXOPT_LOOKUP_S64(limit, config->args, "-limit", false, false); 1541 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);1522 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1542 1523 if (state) { 1543 1524 if (strcmp(state, "enabled") && strcmp(state, "disabled")) { … … 1555 1536 PXOPT_COPY_STR(config->args, where, "-dest_name", "rcDestination.name", "=="); 1556 1537 PXOPT_COPY_S64(config->args, where, "-target_id", "target_id", "=="); 1557 PXOPT_COPY_STR(config->args, where, "- label", "label", "LIKE");1538 PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "LIKE"); 1558 1539 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "LIKE"); 1559 1540 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); … … 1658 1639 PXOPT_COPY_S64(config->args, where, "-target_id", "target_id", "=="); 1659 1640 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 1660 PXOPT_COPY_STR(config->args, where, "- label", "label", "LIKE");1641 PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "LIKE"); 1661 1642 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "LIKE"); 1662 1643 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); -
branches/eam_branches/20090820/ippTools/src/disttool.h
r25766 r25870 26 26 DISTTOOL_MODE_NONE = 0x0, 27 27 DISTTOOL_MODE_DEFINEBYQUERY, 28 DISTTOOL_MODE_DEFINERUN,29 28 DISTTOOL_MODE_UPDATERUN, 30 29 DISTTOOL_MODE_REVERTRUN, -
branches/eam_branches/20090820/ippTools/src/disttoolConfig.c
r25766 r25870 50 50 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not needed", false); 51 51 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label for run", NULL); 52 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "select by dist_group", NULL); 52 53 53 54 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-dry_run", 0, "don't queue runs just display what would be selected", false); … … 58 59 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-chip_id", 0, "define chip_id", 0); 59 60 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define chip_id", 0); 60 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "select by label", NULL); 61 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "select by run label", NULL); 62 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-dist_group", 0, "select by dist_group", NULL); 61 63 62 64 psMetadataAddU64(definebyqueryArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 63 65 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 64 65 // -definerun66 psMetadata *definerunArgs = psMetadataAlloc();67 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-stage", 0, "define stage for bundle (required)", NULL);68 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id (required)", 0);69 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-outroot", 0, "define output destination (required)", NULL);70 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-target_id", 0, "define target_id (required)", 0);71 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-clean", 0, "build clean distribution bundle", false);72 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not needed", false);73 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_label", 0, "define label for run", NULL);74 66 75 67 // -updaterun … … 139 131 psMetadataAddS64(pendingfilesetArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 140 132 psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "limit results to label", NULL); 133 psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-dist_group", PS_META_DUPLICATE_OK, "limit results to dist_group", NULL); 141 134 psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-stage", 0, "limit results to runs for stage", NULL); 142 135 psMetadataAddU64(pendingfilesetArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); … … 219 212 // -definetarget 220 213 psMetadata *definetargetArgs = psMetadataAlloc(); 221 psMetadataAddStr(definetargetArgs, PS_LIST_TAIL, "- label", 0, "define label(required)", NULL);214 psMetadataAddStr(definetargetArgs, PS_LIST_TAIL, "-dist_group", 0, "define dist_group (required)", NULL); 222 215 psMetadataAddStr(definetargetArgs, PS_LIST_TAIL, "-filter", 0, "define filter (required)", NULL); 223 216 psMetadataAddStr(definetargetArgs, PS_LIST_TAIL, "-stage", 0, "define stage (required)", NULL); … … 230 223 psMetadataAddS64(updatetargetArgs, PS_LIST_TAIL, "-target_id", 0, "define target_id", 0); 231 224 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-stage", 0, "define stage", NULL); 232 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-set_state", 0, "define state", NULL); 233 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 225 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-dist_group", 0, "define dist_group", NULL); 234 226 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-filter", 0, "define filter", NULL); 227 228 psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-set_state", 0, "define new state", NULL); 235 229 236 230 // -listtarget 237 231 psMetadata *listtargetArgs = psMetadataAlloc(); 238 232 psMetadataAddS64(listtargetArgs, PS_LIST_TAIL, "-target_id", 0, "list target with target_id", 0); 239 psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "- label", 0, "list targets for label", NULL);233 psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-dist_group", 0, "list targets for dist_group", NULL); 240 234 psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-filter", 0, "define filter", NULL); 241 235 psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-stage", 0, "list targets for stage", NULL); … … 252 246 psMetadataAddS64(defineinterestArgs, PS_LIST_TAIL, "-target_id", 0, "define target_id", 0); 253 247 psMetadataAddStr(defineinterestArgs, PS_LIST_TAIL, "-stage", 0, "define stage", NULL); 254 psMetadataAddStr(defineinterestArgs, PS_LIST_TAIL, "- label", 0, "define label", NULL);248 psMetadataAddStr(defineinterestArgs, PS_LIST_TAIL, "-dist_group", 0, "define dist_group", NULL); 255 249 psMetadataAddStr(defineinterestArgs, PS_LIST_TAIL, "-filter", 0, "define filter (LIKE comparison)", NULL); 256 250 psMetadataAddBool(defineinterestArgs, PS_LIST_TAIL,"-clean", 0, "list clean targets", false); … … 271 265 psMetadataAddS64(listinterestsArgs, PS_LIST_TAIL, "-int_id", 0, "list interests with int_id", 0); 272 266 psMetadataAddStr(listinterestsArgs, PS_LIST_TAIL, "-dest_name", 0, "list interests for destinationn name)", NULL); 273 psMetadataAddStr(listinterestsArgs, PS_LIST_TAIL, "- label", 0, "list interests for label(LIKE comparison)", NULL);267 psMetadataAddStr(listinterestsArgs, PS_LIST_TAIL, "-dist_group", 0, "list interests for dist_group (LIKE comparison)", NULL); 274 268 psMetadataAddStr(listinterestsArgs, PS_LIST_TAIL, "-filter", 0, "list interests by filter (LIKE comparison)", NULL); 275 269 psMetadataAddStr(listinterestsArgs, PS_LIST_TAIL, "-stage", 0, "list interests for stage", NULL); … … 284 278 285 279 PXOPT_ADD_MODE("-definebyquery", "", DISTTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 286 PXOPT_ADD_MODE("-definerun", "", DISTTOOL_MODE_DEFINERUN, definerunArgs);287 280 PXOPT_ADD_MODE("-updaterun", "", DISTTOOL_MODE_UPDATERUN, updaterunArgs); 288 281 PXOPT_ADD_MODE("-revertrun", "", DISTTOOL_MODE_REVERTRUN, revertrunArgs); -
branches/eam_branches/20090820/ippTools/src/faketool.c
r25766 r25870 177 177 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 178 178 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 179 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 180 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 181 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 179 182 180 183 // default … … 265 268 266 269 // queue the exp 267 if (!pxfakeQueueByCamID(config, cam_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) {270 if (!pxfakeQueueByCamID(config, cam_id, workdir, label, data_group ? data_group : label, dist_group, reduction, expgroup, dvodb, tess_id, end_stage, note)) { 268 271 if (!psDBRollback(config->dbh)) { 269 272 psError(PS_ERR_UNKNOWN, false, "database error"); … … 330 333 PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "sun_angle", "<"); 331 334 PXOPT_COPY_STR(config->args, where, "-label", "fakeRun.label", "=="); 332 333 if (!psListLength(where->list) 334 && !psMetadataLookupBool(NULL, config->args, "-all")) { 335 PXOPT_COPY_STR(config->args, where, "-data_group", "fakeRun.data_group", "=="); 336 PXOPT_COPY_STR(config->args, where, "-dist_group", "fakeRun.dist_group", "=="); 337 338 if (!psListLength(where->list)) { 335 339 psFree(where); 336 340 where = NULL; … … 339 343 } 340 344 341 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 342 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 343 344 if ((!state) && (!label)) { 345 psError(PXTOOLS_ERR_DATA, false, "parameters are required"); 346 psFree(where); 347 return false; 348 } 349 350 if (state) { 351 // set fakeRun.state to state 352 if (!pxfakeRunSetStateByQuery(config, where, state)) { 353 psFree(where); 354 return false; 355 } 356 } 357 358 if (label) { 359 // set fakeRun.label to label 360 if (!pxfakeRunSetLabelByQuery(config, where, label)) { 361 psFree(where); 362 return false; 363 } 364 } 365 345 psString query = psStringCopy("UPDATE fakeRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 346 347 // pxUpdateRun gets parameters from config->args and updates 348 bool result = pxUpdateRun(config, where, &query, "fakeRun", true); 349 if (!result) { 350 psError(PXTOOLS_ERR_DATA, false, "pxUpdateRun failed"); 351 } 352 353 psFree(query); 366 354 psFree(where); 367 355 368 return true;356 return result; 369 357 } 370 358 … … 1162 1150 fakeRun->workdir, 1163 1151 fakeRun->label, 1152 fakeRun->data_group, 1153 fakeRun->dist_group, 1164 1154 fakeRun->dvodb, 1165 1155 fakeRun->tess_id, 1166 1156 fakeRun->reduction, 1167 fakeRun->end_stage 1157 fakeRun->end_stage, 1158 NULL // note does not propagate 1168 1159 )) { 1169 1160 psError(PS_ERR_UNKNOWN, false, "failed to queue warpRun"); … … 1279 1270 return false; 1280 1271 } 1281 1272 if (!pxExportVersion(config, f)) { 1273 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1274 return false; 1275 } 1282 1276 psMetadata *where = psMetadataAlloc(); 1283 1277 PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "=="); … … 1360 1354 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1361 1355 1362 fprintf (stdout, "---- input ----\n"); 1356 #ifdef notdef 1357 fprintf (stderr, "---- input ----\n"); 1363 1358 psMetadataPrint (stderr, input, 1); 1364 1359 #endif 1360 1361 if (!pxCheckImportVersion(config, input)) { 1362 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1363 return false; 1364 } 1365 1365 psMetadataItem *item = psMetadataLookup (input, "fakeRun"); 1366 1366 psAssert (item, "entry not in input?"); -
branches/eam_branches/20090820/ippTools/src/faketoolConfig.c
r25766 r25870 93 93 psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_tess_id", 0, "define tessellation identifier", NULL); 94 94 psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_end_stage", 0, "define end stage", NULL); 95 psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 96 psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 97 psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 95 98 psMetadataAddBool(queueArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 96 99 psMetadataAddBool(queueArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); … … 139 142 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sun_angle_min", 0, "define min solar angle", NAN); 140 143 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sun_angle_max", 0, "define max solar angle", NAN); 144 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 141 145 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 146 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-data_group", 0, "search by data_group", NULL); 147 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-dist_group", 0, "search by data_group", NULL); 142 148 143 149 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 144 150 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 145 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 151 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 152 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 153 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 146 154 147 155 // -pendingexp -
branches/eam_branches/20090820/ippTools/src/flatcorr.c
r24140 r25870 33 33 #include "pxtools.h" 34 34 #include "pxchip.h" 35 #include "pxcam.h" 36 #include "pxadd.h" 35 37 #include "flatcorr.h" 36 38 … … 38 40 static bool definerunMode(pxConfig *config); 39 41 static bool addchipMode(pxConfig *config); 42 static bool dropchipMode(pxConfig *config); 40 43 static bool addcameraMode(pxConfig *config); 41 static bool dropchipMode(pxConfig *config);42 44 static bool dropcameraMode(pxConfig *config); 45 static bool advancecameraMode(pxConfig *config); 46 static bool advanceaddstarMode(pxConfig *config); 43 47 static bool pendingprocessMode(pxConfig *config); 44 48 static bool addprocessMode(pxConfig *config); … … 46 50 static bool inputexpMode(pxConfig *config); 47 51 static bool inputimfileMode(pxConfig *config); 48 static bool exportrunMode(pxConfig *config);49 static bool importrunMode(pxConfig *config);50 52 51 53 static bool setflatcorrRunState(pxConfig *config, psS64 corr_id, const char *state); … … 72 74 MODECASE(FLATCORR_MODE_DEFINERUN, definerunMode); 73 75 MODECASE(FLATCORR_MODE_ADDCHIP, addchipMode); 76 MODECASE(FLATCORR_MODE_DROPCHIP, dropchipMode); 74 77 MODECASE(FLATCORR_MODE_ADDCAMERA, addcameraMode); 75 MODECASE(FLATCORR_MODE_DROPCHIP, dropchipMode);76 78 MODECASE(FLATCORR_MODE_DROPCAMERA, dropcameraMode); 79 MODECASE(FLATCORR_MODE_ADVANCECAMERA, advancecameraMode); 80 MODECASE(FLATCORR_MODE_ADVANCEADDSTAR, advanceaddstarMode); 77 81 MODECASE(FLATCORR_MODE_PENDINGPROCESS, pendingprocessMode); 78 82 MODECASE(FLATCORR_MODE_ADDPROCESS, addprocessMode); … … 80 84 MODECASE(FLATCORR_MODE_INPUTEXP, inputexpMode); 81 85 MODECASE(FLATCORR_MODE_INPUTIMFILE, inputimfileMode); 82 MODECASE(FLATCORR_MODE_EXPORTRUN, exportrunMode);83 MODECASE(FLATCORR_MODE_IMPORTRUN, importrunMode);84 86 default: 85 87 psAbort("invalid option (this should not happen)"); … … 131 133 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 132 134 PXOPT_LOOKUP_STR(region, config->args, "-set_region", false, false); 135 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 133 136 134 137 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); … … 233 236 234 237 // queue the exp : force this to stop at the chip stage 235 psS64 chip_id = pxchipQueueByExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, "chip");238 psS64 chip_id = pxchipQueueByExpTag(config, exp_id, workdir, label, label, NULL, reduction, expgroup, dvodb, tess_id, "chip", note); 236 239 if (!chip_id) { 237 240 if (!psDBRollback(config->dbh)) { … … 297 300 // start a transaction so we don't end up with an exp without any associted 298 301 // imfiles 299 if (!psDBTransaction(config->dbh)) {300 psError(PS_ERR_UNKNOWN, false, "database error");301 return false;302 }302 // if (!psDBTransaction(config->dbh)) { 303 // psError(PS_ERR_UNKNOWN, false, "database error"); 304 // return false; 305 // } 303 306 304 307 // create a new flatcorrRun … … 333 336 row->corr_id = corr_id; 334 337 338 // if (!psDBCommit(config->dbh)) { 339 // psError(PS_ERR_UNKNOWN, false, "database error"); 340 // return false; 341 // } 342 335 343 flatcorrRunPrintObject (stdout, row, !simple); 336 344 return true; … … 378 386 } 379 387 388 static bool addcameraMode(pxConfig *config) 389 { 390 PS_ASSERT_PTR_NON_NULL(config, false); 391 392 // required 393 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 394 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false); 395 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", true, false); 396 397 // add a flatcorrCamLink (initial state has include = TRUE) 398 // XXX should add checks that the chip_id and corr_id are in ChipLink 399 if (!flatcorrCamLinkInsert(config->dbh, corr_id, chip_id, cam_id, 1)) { 400 psError(PS_ERR_UNKNOWN, false, "database error"); 401 return false; 402 } 403 404 return true; 405 } 406 407 static bool dropcameraMode(pxConfig *config) 408 { 409 PS_ASSERT_PTR_NON_NULL(config, false); 410 411 // required 412 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 413 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", true, false); 414 415 // UPDATE flatcorrCamLink set include = 0 where corr_id = %lld AND cam_id = %lld 416 psString query = pxDataGet("flatcorr_dropcamera.sql"); 417 if (!query) { 418 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 419 return false; 420 } 421 422 if (!p_psDBRunQueryF(config->dbh, query, (long long) corr_id, (long long) cam_id)) { 423 psError(PS_ERR_UNKNOWN, false, "database error"); 424 psFree(query); 425 return false; 426 } 427 428 return true; 429 } 430 380 431 // select the flatcorr chip runs that have completed and for which there is no camera entry 381 432 // queue a new camera run for them 382 static bool ad dcameraMode(pxConfig *config)433 static bool advancecameraMode(pxConfig *config) 383 434 { 384 435 PS_ASSERT_PTR_NON_NULL(config, false); … … 387 438 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 388 439 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 440 441 psMetadata *where = psMetadataAlloc(); 442 pxAddLabelSearchArgs (config, where, "-label", "flatcorrRun.label", "=="); 389 443 390 444 psString query = pxDataGet("flatcorr_chiprundone.sql"); … … 393 447 return false; 394 448 } 449 450 if (where && psListLength(where->list)) { 451 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 452 psStringAppend(&query, " AND %s", whereClause); 453 psFree(whereClause); 454 } 455 psFree(where); 395 456 396 457 // treat limit == 0 as "no limit" … … 463 524 row->workdir, 464 525 row->label, 526 row->data_group, 527 row->dist_group, 465 528 row->reduction, 466 529 row->expgroup, 467 530 row->dvodb, 468 531 row->tess_id, 469 "camera")) { 532 "camera", 533 NULL // note does not propragate 534 )) { 470 535 if (!psDBRollback(config->dbh)) { 471 536 psError(PS_ERR_UNKNOWN, false, "database error"); … … 502 567 } 503 568 504 static bool dropcameraMode(pxConfig *config) 505 { 506 PS_ASSERT_PTR_NON_NULL(config, false); 507 508 // required 509 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 510 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", true, false); 511 512 // UPDATE flatcorrCamLink set include = 0 where corr_id = %lld AND cam_id = %lld 513 psString query = pxDataGet("flatcorr_dropcamera.sql"); 514 if (!query) { 515 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 516 return false; 517 } 518 519 if (!p_psDBRunQueryF(config->dbh, query, (long long) corr_id, (long long) cam_id)) { 520 psError(PS_ERR_UNKNOWN, false, "database error"); 521 psFree(query); 522 return false; 523 } 524 525 return true; 526 } 527 528 // select the flatcorr chip runs that have completed and for which there is no camera entry 529 // queue a new camera run for them 530 static bool pendingprocessMode(pxConfig *config) 569 // Select the flatcorr camera runs that have completed and for which there is no addstar 570 // entry. Queue a new addstar run for them 571 static bool advanceaddstarMode(pxConfig *config) 531 572 { 532 573 PS_ASSERT_PTR_NON_NULL(config, false); … … 534 575 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 535 576 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 577 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 536 578 537 579 psMetadata *where = psMetadataAlloc(); 538 pxAddLabelSearchArgs (config, where, "-label", " label", "==");539 540 psString query = pxDataGet("flatcorr_ pendingprocess.sql");580 pxAddLabelSearchArgs (config, where, "-label", "flatcorrRun.label", "=="); 581 582 psString query = pxDataGet("flatcorr_camerarundone.sql"); 541 583 if (!query) { 542 584 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 575 617 } 576 618 619 if (pretend) { 620 // negative simple so the default is true 621 if (!ippdbPrintMetadatas(stdout, output, "flatcorr_addcamera", !simple)) { 622 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 623 psFree(output); 624 return false; 625 } 626 } 627 628 // start a transaction so we don't end up with an exp without any associted 629 // imfiles 630 if (!psDBTransaction(config->dbh)) { 631 psError(PS_ERR_UNKNOWN, false, "database error"); 632 psFree(output); 633 return false; 634 } 635 636 // loop over our list of chipRun rows 637 for (long i = 0; i < psArrayLength(output); i++) { 638 psMetadata *md = output->data[i]; 639 640 bool status; 641 psS64 corr_id = psMetadataLookupS64(&status, md, "corr_id"); 642 if (!status) { 643 if (!psDBRollback(config->dbh)) { 644 psError(PS_ERR_UNKNOWN, false, "database error"); 645 } 646 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for corr_id"); 647 psFree(output); 648 return false; 649 } 650 651 camRunRow *row = camRunObjectFromMetadata(md); 652 if (!row) { 653 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 654 psFree(output); 655 return false; 656 } 657 658 // queue the exp : force image_only to be false (flatcorr is meaningless with just image info) 659 if (!pxaddQueueByCamID( 660 config, 661 row->cam_id, 662 row->workdir, 663 row->reduction, 664 row->label, 665 row->data_group, 666 row->dvodb, 667 NULL, // note is not propagated 668 0)) { 669 if (!psDBRollback(config->dbh)) { 670 psError(PS_ERR_UNKNOWN, false, "database error"); 671 } 672 psError(PS_ERR_UNKNOWN, false, 673 "failed to trying to queue cam_id: %" PRId64, row->cam_id); 674 psFree(row); 675 psFree(output); 676 return false; 677 } 678 679 // figure out the ID of the flatcorrRun we just created 680 psS64 add_id = psDBLastInsertID(config->dbh); 681 682 // add the addRun entry to the flatcorrAddstarLink table (include is TRUE) 683 if (!flatcorrAddstarLinkInsert(config->dbh, corr_id, row->cam_id, add_id, 1)) { 684 if (!psDBRollback(config->dbh)) { 685 psError(PS_ERR_UNKNOWN, false, "database error"); 686 } 687 psError(PS_ERR_UNKNOWN, false, "database error"); 688 return false; 689 } 690 psFree(row); 691 } 692 psFree(output); 693 694 if (!psDBCommit(config->dbh)) { 695 psError(PS_ERR_UNKNOWN, false, "database error"); 696 return false; 697 } 698 699 return false; 700 } 701 702 // select the flatcorr chip runs that have completed and for which there is no camera entry 703 // queue a new camera run for them 704 static bool pendingprocessMode(pxConfig *config) 705 { 706 PS_ASSERT_PTR_NON_NULL(config, false); 707 708 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 709 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 710 711 psMetadata *where = psMetadataAlloc(); 712 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 713 714 psString query = pxDataGet("flatcorr_pendingprocess.sql"); 715 if (!query) { 716 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 717 return false; 718 } 719 720 if (where && psListLength(where->list)) { 721 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 722 psStringAppend(&query, " AND %s", whereClause); 723 psFree(whereClause); 724 } 725 psFree(where); 726 727 // treat limit == 0 as "no limit" 728 if (limit) { 729 psString limitString = psDBGenerateLimitSQL(limit); 730 psStringAppend(&query, " %s", limitString); 731 psFree(limitString); 732 } 733 734 if (!p_psDBRunQuery(config->dbh, query)) { 735 psError(PS_ERR_UNKNOWN, false, "database error"); 736 psFree(query); 737 return false; 738 } 739 740 psArray *output = p_psDBFetchResult(config->dbh); 741 if (!output) { 742 psError(PS_ERR_UNKNOWN, false, "database error"); 743 return false; 744 } 745 if (!psArrayLength(output)) { 746 psTrace("flatcorr", PS_LOG_INFO, "no rows found"); 747 psFree(output); 748 return true; 749 } 750 577 751 if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) { 578 752 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 579 753 psFree(output); 580 754 return false; 755 } 756 757 return true; 758 } 759 760 // XXX need a fault state 761 static bool addprocessMode(pxConfig *config) 762 { 763 PS_ASSERT_PTR_NON_NULL(config, false); 764 765 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 766 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 767 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 768 769 char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64; 770 771 if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) { 772 psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id); 773 return false; 774 } 775 776 return true; 777 } 778 779 static bool updaterunMode(pxConfig *config) 780 { 781 PS_ASSERT_PTR_NON_NULL(config, false); 782 783 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 784 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 785 786 if (!setflatcorrRunState(config, corr_id, state)) { 787 if (!psDBRollback(config->dbh)) { 788 psError(PS_ERR_UNKNOWN, false, "database error"); 789 } 790 psError(PS_ERR_UNKNOWN, false, "failed to set run state"); 791 return false; 581 792 } 582 793 … … 688 899 } 689 900 690 // XXX need a fault state691 static bool addprocessMode(pxConfig *config)692 {693 PS_ASSERT_PTR_NON_NULL(config, false);694 695 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);696 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);697 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);698 699 char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64;700 701 if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) {702 psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id);703 return false;704 }705 706 return true;707 }708 709 static bool updaterunMode(pxConfig *config)710 {711 PS_ASSERT_PTR_NON_NULL(config, false);712 713 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);714 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);715 716 if (!setflatcorrRunState(config, corr_id, state)) {717 if (!psDBRollback(config->dbh)) {718 psError(PS_ERR_UNKNOWN, false, "database error");719 }720 psError(PS_ERR_UNKNOWN, false, "failed to set run state");721 return false;722 }723 724 return true;725 }726 727 901 static bool setflatcorrRunState(pxConfig *config, psS64 corr_id, const char *state) 728 902 { … … 748 922 return true; 749 923 } 750 751 bool exportrunMode(pxConfig *config)752 {753 typedef struct ExportTable {754 char tableName[80];755 char sqlFilename[80];756 } ExportTable;757 758 int numExportTables = 3;759 760 PS_ASSERT_PTR_NON_NULL(config, NULL);761 762 PXOPT_LOOKUP_S64(det_id, config->args, "-corr_id", true, false);763 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false);764 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);765 766 FILE *f = fopen (outfile, "w");767 if (f == NULL) {768 psError(PS_ERR_UNKNOWN, false, "failed to open output file");769 return false;770 }771 772 psMetadata *where = psMetadataAlloc();773 PXOPT_COPY_S64(config->args, where, "-corr_id", "corr_id", "==");774 775 ExportTable tables [] = {776 {"flatcorrRun", "flatcorr_export_run.sql"},777 {"flatcorrCamLink", "flatcorr_export_cam_link.sql"},778 {"flatcorrChipLink", "flatcorr_export_chip_link.sql"},779 };780 781 for (int i=0; i < numExportTables; i++) {782 psString query = pxDataGet(tables[i].sqlFilename);783 if (!query) {784 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");785 return false;786 }787 788 if (where && psListLength(where->list)) {789 psString whereClause = psDBGenerateWhereSQL(where, NULL);790 psStringAppend(&query, " %s", whereClause);791 psFree(whereClause);792 }793 794 // treat limit == 0 as "no limit"795 if (limit) {796 psString limitString = psDBGenerateLimitSQL(limit);797 psStringAppend(&query, " %s", limitString);798 psFree(limitString);799 }800 801 if (!p_psDBRunQuery(config->dbh, query)) {802 psError(PS_ERR_UNKNOWN, false, "database error");803 psFree(query);804 return false;805 }806 psFree(query);807 808 psArray *output = p_psDBFetchResult(config->dbh);809 if (!output) {810 psError(PS_ERR_UNKNOWN, false, "database error");811 return false;812 }813 if (!psArrayLength(output)) {814 psTrace("regtool", PS_LOG_INFO, "no rows found");815 psFree(output);816 return true;817 }818 819 // we must write the export table in non-simple (true) format820 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {821 psError(PS_ERR_UNKNOWN, false, "failed to print array");822 psFree(output);823 return false;824 }825 psFree(output);826 }827 828 fclose (f);829 830 return true;831 }832 833 bool importrunMode(pxConfig *config)834 {835 unsigned int nFail;836 psMetadataItem *item, *entry;837 838 int numImportTables = 3;839 840 char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"};841 842 PS_ASSERT_PTR_NON_NULL(config, NULL);843 844 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false);845 846 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false);847 848 fprintf (stdout, "---- input ----\n");849 psMetadataPrint (stderr, input, 1);850 851 for (int i = 0; i < numImportTables; i++) {852 item = psMetadataLookup (input, tables[i]);853 psAssert (item, "entry not in input?");854 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");855 856 entry = psListGet (item->data.list, 0);857 assert (entry);858 assert (entry->type == PS_DATA_METADATA);859 860 switch (i) {861 case 0:862 {863 flatcorrRunRow *flatcorrRun = flatcorrRunObjectFromMetadata (entry->data.md);864 flatcorrRunInsertObject (config->dbh, flatcorrRun);865 866 // fprintf (stdout, "---- flatcorr run ----\n");867 // psMetadataPrint (stderr, entry->data.md, 1);868 break;869 }870 case 1:871 {872 flatcorrCamLinkRow *flatcorrCamLink = flatcorrCamLinkObjectFromMetadata (entry->data.md);873 flatcorrCamLinkInsertObject (config->dbh, flatcorrCamLink);874 875 // fprintf (stdout, "---- flatcorr cam link ----\n");876 // psMetadataPrint (stderr, entry->data.md, 1);877 break;878 }879 case 2:880 {881 flatcorrChipLinkRow *flatcorrChipLink = flatcorrChipLinkObjectFromMetadata (entry->data.md);882 flatcorrChipLinkInsertObject (config->dbh, flatcorrChipLink);883 884 // fprintf (stdout, "---- flatcorr chip link ----\n");885 // psMetadataPrint (stderr, entry->data.md, 1);886 break;887 }888 }889 }890 return true;891 } -
branches/eam_branches/20090820/ippTools/src/flatcorr.h
r23310 r25870 28 28 FLATCORR_MODE_DEFINERUN, 29 29 FLATCORR_MODE_ADDCHIP, 30 FLATCORR_MODE_DROPCHIP, 30 31 FLATCORR_MODE_ADDCAMERA, 31 FLATCORR_MODE_DROPCHIP,32 32 FLATCORR_MODE_DROPCAMERA, 33 FLATCORR_MODE_ADVANCECAMERA, 34 FLATCORR_MODE_ADVANCEADDSTAR, 33 35 FLATCORR_MODE_PENDINGPROCESS, 34 36 FLATCORR_MODE_ADDPROCESS, … … 36 38 FLATCORR_MODE_INPUTEXP, 37 39 FLATCORR_MODE_INPUTIMFILE, 38 FLATCORR_MODE_EXPORTRUN,39 FLATCORR_MODE_IMPORTRUN40 40 } flatcorrMode; 41 41 -
branches/eam_branches/20090820/ippTools/src/flatcorrConfig.c
r24140 r25870 65 65 // -definerun 66 66 psMetadata *definerunArgs = psMetadataAlloc(); 67 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-inst", 0, "define camera", NULL); 68 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope", NULL); 67 69 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-det_type", 0, "define detrend type to be generated", NULL); 68 70 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 88 90 // -addcamera 89 91 psMetadata *addcameraArgs = psMetadataAlloc(); 90 psMetadataAdd U64 (addcameraArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);91 psMetadataAdd Bool(addcameraArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);92 psMetadataAdd Bool(addcameraArgs, PS_LIST_TAIL, "-pretend", 0, "use the simple output format", false);92 psMetadataAddS64(addcameraArgs, PS_LIST_TAIL, "-corr_id", 0, "define Flat Correction ID (required)", 0); 93 psMetadataAddS64(addcameraArgs, PS_LIST_TAIL, "-chip_id", 0, "define Chip ID (required)", 0); 94 psMetadataAddS64(addcameraArgs, PS_LIST_TAIL, "-cam_id", 0, "define Camera ID (required)", 0); 93 95 94 96 // -dropcamera … … 96 98 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-corr_id", 0, "define Flat Correction ID (required)", 0); 97 99 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-cam_id", 0, "define Camera ID (required)", 0); 100 101 // -advancecamera 102 psMetadata *advancecameraArgs = psMetadataAlloc(); 103 psMetadataAddU64 (advancecameraArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 104 psMetadataAddBool(advancecameraArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 105 psMetadataAddBool(advancecameraArgs, PS_LIST_TAIL, "-pretend", 0, "use the simple output format", false); 106 psMetadataAddStr(advancecameraArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 107 108 // -advanceaddstar 109 psMetadata *advanceaddstarArgs = psMetadataAlloc(); 110 psMetadataAddU64 (advanceaddstarArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 111 psMetadataAddBool(advanceaddstarArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 112 psMetadataAddBool(advanceaddstarArgs, PS_LIST_TAIL, "-pretend", 0, "use the simple output format", false); 113 psMetadataAddStr(advanceaddstarArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 98 114 99 115 // -pendingprocess … … 142 158 psMetadata *modes = psMetadataAlloc(); 143 159 144 PXOPT_ADD_MODE("-definebyquery", "create a new, populated flat correction run", FLATCORR_MODE_DEFINEBYQUERY, definebyqueryArgs);145 PXOPT_ADD_MODE("-definerun", "create a new, empty flat correction run", FLATCORR_MODE_DEFINERUN, definerunArgs);146 PXOPT_ADD_MODE("-addchip", "add a chip to a flat correction run",FLATCORR_MODE_ADDCHIP, addchipArgs);147 PXOPT_ADD_MODE("-addcamera", " migrate completed chips to camera stage analysis",FLATCORR_MODE_ADDCAMERA, addcameraArgs);148 PXOPT_ADD_MODE("- dropchip", "drop a chip from a flat correction run", FLATCORR_MODE_DROPCHIP, dropchipArgs);149 PXOPT_ADD_MODE("- dropcamera", "drop an exposure (camera stage analysis)", FLATCORR_MODE_DROPCAMERA, dropcameraArgs);150 PXOPT_ADD_MODE("- pendingprocess", "show flat correction runs needing to be processed", FLATCORR_MODE_PENDINGPROCESS, pendingprocessArgs);151 PXOPT_ADD_MODE("- addprocess", "report completed flat correction analysis", FLATCORR_MODE_ADDPROCESS, addprocessArgs);152 PXOPT_ADD_MODE("- updaterun", "change a flat calibration run's state", FLATCORR_MODE_UPDATERUN, updaterunArgs);153 PXOPT_ADD_MODE("- inputexp", "list exposures for a correction run", FLATCORR_MODE_INPUTEXP, inputexpArgs);154 PXOPT_ADD_MODE("- inputimfile", "list imfiles for a chip run", FLATCORR_MODE_INPUTIMFILE, inputimfileArgs);155 PXOPT_ADD_MODE("- exportrun", "export run for import on other database", FLATCORR_MODE_EXPORTRUN, exportrunArgs);156 PXOPT_ADD_MODE("-i mportrun", "import run from metadata file", FLATCORR_MODE_IMPORTRUN, importrunArgs);160 PXOPT_ADD_MODE("-definebyquery", "create a new, populated flat correction run", FLATCORR_MODE_DEFINEBYQUERY, definebyqueryArgs); 161 PXOPT_ADD_MODE("-definerun", "create a new, empty flat correction run", FLATCORR_MODE_DEFINERUN, definerunArgs); 162 PXOPT_ADD_MODE("-addchip", "add an existing chip run to a flat correction run", FLATCORR_MODE_ADDCHIP, addchipArgs); 163 PXOPT_ADD_MODE("-addcamera", "add an existing camera run to a flat correction run", FLATCORR_MODE_ADDCAMERA, addcameraArgs); 164 PXOPT_ADD_MODE("-advancecamera", "migrate completed chips to camera stage analysis", FLATCORR_MODE_ADVANCECAMERA, advancecameraArgs); 165 PXOPT_ADD_MODE("-advanceaddstar", "migrate completed exposures to addstar processing", FLATCORR_MODE_ADVANCEADDSTAR, advanceaddstarArgs); 166 PXOPT_ADD_MODE("-dropchip", "drop a chip from a flat correction run", FLATCORR_MODE_DROPCHIP, dropchipArgs); 167 PXOPT_ADD_MODE("-dropcamera", "drop an exposure (camera stage analysis)", FLATCORR_MODE_DROPCAMERA, dropcameraArgs); 168 PXOPT_ADD_MODE("-pendingprocess", "show flat correction runs needing to be processed", FLATCORR_MODE_PENDINGPROCESS, pendingprocessArgs); 169 PXOPT_ADD_MODE("-addprocess", "report completed flat correction analysis", FLATCORR_MODE_ADDPROCESS, addprocessArgs); 170 PXOPT_ADD_MODE("-updaterun", "change a flat calibration run's state", FLATCORR_MODE_UPDATERUN, updaterunArgs); 171 PXOPT_ADD_MODE("-inputexp", "list exposures for a correction run", FLATCORR_MODE_INPUTEXP, inputexpArgs); 172 PXOPT_ADD_MODE("-inputimfile", "list imfiles for a chip run", FLATCORR_MODE_INPUTIMFILE, inputimfileArgs); 157 173 158 174 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/eam_branches/20090820/ippTools/src/magicdstool.c
r25766 r25870 33 33 34 34 static bool definebyqueryMode(pxConfig *config); 35 static psS64 definerunMode(pxConfig *config);36 35 static bool updaterunMode(pxConfig *config); 37 36 static bool todestreakMode(pxConfig *config); … … 43 42 static bool torevertMode(pxConfig *config); 44 43 static bool completedrevertMode(pxConfig *config); 45 46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); 47 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id);44 static bool tocleanupMode(pxConfig *config); 45 46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psMetadata *where, const char *state); 48 47 49 48 # define MODECASE(caseName, func) \ … … 66 65 switch (config->mode) { 67 66 MODECASE(MAGICDSTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 68 MODECASE(MAGICDSTOOL_MODE_DEFINERUN, definerunMode);69 67 MODECASE(MAGICDSTOOL_MODE_UPDATERUN, updaterunMode); 70 68 MODECASE(MAGICDSTOOL_MODE_TODESTREAK, todestreakMode); … … 76 74 MODECASE(MAGICDSTOOL_MODE_TOREVERT, torevertMode); 77 75 MODECASE(MAGICDSTOOL_MODE_COMPLETEDREVERT, completedrevertMode); 76 MODECASE(MAGICDSTOOL_MODE_TOCLEANUP, tocleanupMode); 78 77 default: 79 78 psAbort("invalid option (this should not happen)"); … … 108 107 PXOPT_LOOKUP_BOOL(noreplace, config->args, "-noreplace", false); 109 108 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 109 PXOPT_LOOKUP_STR(set_data_group, config->args, "-set_data_group", false, false); 110 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 110 111 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 111 112 PXOPT_LOOKUP_BOOL(dry_run, config->args, "-dry_run", false); … … 246 247 psS64 cam_id = psMetadataLookupS64(NULL, row, "cam_id"); 247 248 psString magicRunLabel = psMetadataLookupStr(NULL, row, "label"); 249 psString magicRunDataGroup = psMetadataLookupStr(NULL, row, "data_group"); 248 250 psString magicRunWorkdir = psMetadataLookupStr(NULL, row, "workdir"); 249 251 … … 267 269 cam_id, 268 270 set_label ? set_label : magicRunLabel, 271 set_data_group ? set_data_group : magicRunDataGroup, 269 272 outroot, 270 273 recoveryroot, 271 274 noreplace ? 0 :1, // re_place 272 0); // remove 275 0, // remove 276 0, // fault 277 note); // remove 273 278 274 279 psFree(outroot); … … 313 318 } 314 319 315 static psS64 definerunMode(pxConfig *config) 320 321 static bool updaterunMode(pxConfig *config) 316 322 { 317 323 PS_ASSERT_PTR_NON_NULL(config, false); 318 324 319 325 // required 320 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false); 321 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 322 PXOPT_LOOKUP_STR(outroot, config->args, "-outroot", true, false); 323 324 // optional 325 PXOPT_LOOKUP_STR(recoveryroot, config->args, "-recoveryroot", false, false); 326 PXOPT_LOOKUP_BOOL(re_place, config->args, "-replace", false); 327 PXOPT_LOOKUP_BOOL(remove, config->args, "-remove", false); 328 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 329 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 330 331 psS64 stage_id = 0, cam_id = 0; 332 333 if (!magicDSGetIDs(config, stage, magic_id, &stage_id, &cam_id)) { 334 psError(PS_ERR_UNKNOWN, false, "failed to get ids"); 335 return false; 336 } 337 338 magicDSRunRow *run = magicDSRunRowAlloc( 339 0, // ID 340 magic_id, 341 0, // inv_magic_id 342 "new", // state 343 stage, 344 stage_id, 345 cam_id, 346 label, 347 outroot, 348 recoveryroot, 349 re_place, 350 remove 351 ); 352 353 if (!run) { 354 psError(PS_ERR_UNKNOWN, false, "failed to alloc magicRun object"); 355 return false; 356 } 357 if (!magicDSRunInsertObject(config->dbh, run)) { 358 psError(PS_ERR_UNKNOWN, false, "database error"); 359 psFree(run); 360 return false; 361 } 362 363 psS64 magic_ds_id = psDBLastInsertID(config->dbh); 364 run->magic_ds_id = magic_ds_id; 365 366 if (!magicDSRunPrintObject(stdout, run, !simple)) { 367 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 368 psFree(run); 369 return false; 370 } 371 372 psFree(run); 373 374 return magic_id; 375 } 376 377 378 static bool updaterunMode(pxConfig *config) 379 { 380 PS_ASSERT_PTR_NON_NULL(config, false); 381 382 // required 383 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false); 384 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 385 386 if (state) { 387 // set detRun.state to state 388 return setmagicDSRunState(config, magic_ds_id, state); 389 } 390 391 return true; 326 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 327 328 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false); 329 if (magic_ds_id) { 330 331 return setmagicDSRunState(config, magic_ds_id, NULL, state); 332 333 } else if (!strcmp(state, "full")) { 334 psError(PS_ERR_UNKNOWN, true, "magic_ds_id is required to update run state to full"); 335 return false; 336 } 337 // we can transition by query as well 338 339 psMetadata *where = psMetadataAlloc(); 340 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 341 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 342 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 343 344 345 if (psListLength(where->list) < 2) { 346 psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required"); 347 return false; 348 } 349 350 351 PXOPT_LOOKUP_BOOL(noreplace, config->args, "-noreplace", false); 352 if (!noreplace) { 353 psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0); 354 } 355 bool result = setmagicDSRunState(config, magic_ds_id, where, state); 356 psFree(where); 357 358 return result; 392 359 } 393 360 … … 670 637 } 671 638 672 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id)673 {674 PS_ASSERT_PTR_NON_NULL(config, false);675 PS_ASSERT_PTR_NON_NULL(stage, false);676 PS_ASSERT_PTR_NON_NULL(stage_id, false);677 PS_ASSERT_PTR_NON_NULL(cam_id, false);678 679 int stageNum = ippStringToStage(stage);;680 if (stageNum == IPP_STAGE_NONE) {681 psError(PXTOOLS_ERR_DATA, false, "%s is not a valid value for stage", stage);682 return false;683 }684 685 psString query = pxDataGet("magicdstool_getrunids.sql");686 if (!query) {687 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");688 return false;689 }690 691 if (!p_psDBRunQueryF(config->dbh, query, magic_id)) {692 psError(PS_ERR_UNKNOWN, false, "database error");693 psFree(query);694 return false;695 }696 psFree(query);697 698 psArray *output = p_psDBFetchResult(config->dbh);699 if (!output) {700 psError(PS_ERR_UNKNOWN, false, "database error");701 return false;702 }703 if (!psArrayLength(output)) {704 psTrace("magicdstool", PS_LOG_INFO, "no rows found");705 psFree(output);706 return true;707 }708 if (psArrayLength(output) > 1) {709 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_id %" PRId64,710 psArrayLength(output), magic_id);711 return false;712 }713 psMetadata *row = output->data[0];714 715 *cam_id = psMetadataLookupS64(NULL, row, "cam_id");716 switch (stageNum) {717 case IPP_STAGE_RAW:718 *stage_id = psMetadataLookupS64(NULL, row, "exp_id");719 break;720 case IPP_STAGE_CHIP:721 *stage_id = psMetadataLookupS64(NULL, row, "chip_id");722 break;723 case IPP_STAGE_CAMERA:724 *stage_id = *cam_id;725 return true;726 case IPP_STAGE_WARP:727 *stage_id = psMetadataLookupS64(NULL, row, "warp_id");728 break;729 case IPP_STAGE_DIFF:730 *stage_id = psMetadataLookupS64(NULL, row, "diff_id");731 break;732 }733 734 return true;735 }736 639 737 640 static bool advancerunMode(pxConfig *config) … … 796 699 797 700 // set magicDSRun.state to 'full' 798 if (!setmagicDSRunState(config, magic_ds_id, "full")) {701 if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) { 799 702 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 800 703 magic_ds_id); … … 994 897 } 995 898 996 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, const char *state) 997 { 998 PS_ASSERT_PTR_NON_NULL(state, false); 999 1000 // check that state is a valid string value 899 static bool validDSRunState(const char *state) 900 { 1001 901 if (!((strcmp(state, "new") == 0) || 1002 902 (strcmp(state, "full") == 0) || 1003 903 (strcmp(state, "restored") == 0) || 1004 904 (strcmp(state, "censored") == 0) || 1005 (strcmp(state, " purged") == 0) ||905 (strcmp(state, "cleaned") == 0) || 1006 906 (strcmp(state, "goto_restored") == 0) || 1007 907 (strcmp(state, "goto_censored") == 0) || 1008 (strcmp(state, "goto_ purged") == 0))908 (strcmp(state, "goto_cleaned") == 0)) 1009 909 ) { 910 return false; 911 } else { 912 return true; 913 } 914 } 915 916 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psMetadata *where, const char *state) 917 { 918 PS_ASSERT_PTR_NON_NULL(state, false); 919 920 if (!validDSRunState(state)) { 1010 921 psError(PS_ERR_UNKNOWN, false, 1011 922 "invalid magicDSRun state: %s", state); … … 1013 924 } 1014 925 1015 char *query = "UPDATE magicDSRun SET state = '%s' WHERE magic_ds_id = %" PRId64; 1016 if (!p_psDBRunQueryF(config->dbh, query, state, magic_ds_id)) { 926 psString query = psStringCopy("UPDATE magicDSRun SET state = '%s'"); 927 if (magic_ds_id) { 928 psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id); 929 } else if (where && psListLength(where->list)) { 930 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 931 psStringAppend(&query, " WHERE %s", whereClause); 932 psFree(whereClause); 933 } else { 934 psError(PS_ERR_UNKNOWN, true, "search arugments are required"); 935 return false; 936 } 937 938 if (!p_psDBRunQueryF(config->dbh, query, state)) { 1017 939 psError(PS_ERR_UNKNOWN, false, 1018 940 "failed to change state for magic_id %" PRId64, magic_ds_id); … … 1178 1100 1179 1101 1102 static bool tocleanupMode(pxConfig *config) 1103 { 1104 PS_ASSERT_PTR_NON_NULL(config, false); 1105 1106 psMetadata *where = psMetadataAlloc(); 1107 1108 PXOPT_COPY_S64(config->args, where, "-stage", "stage", "=="); 1109 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1110 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1111 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1112 1113 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1114 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1115 1116 psString query = pxDataGet("magicdstool_tocleanup.sql"); 1117 if (!query) { 1118 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1119 return false; 1120 } 1121 1122 if (psListLength(where->list)) { 1123 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1124 psStringAppend(&query, " AND %s", whereClause); 1125 psFree(whereClause); 1126 } 1127 psFree(where); 1128 1129 // treat limit == 0 as "no limit" 1130 if (limit) { 1131 psString limitString = psDBGenerateLimitSQL(limit); 1132 psStringAppend(&query, " %s", limitString); 1133 psFree(limitString); 1134 } 1135 1136 if (!p_psDBRunQuery(config->dbh, query)) { 1137 psError(PS_ERR_UNKNOWN, false, "database error"); 1138 psFree(query); 1139 return false; 1140 } 1141 psFree(query); 1142 1143 psArray *output = p_psDBFetchResult(config->dbh); 1144 if (!output) { 1145 psErrorCode err = psErrorCodeLast(); 1146 switch (err) { 1147 case PS_ERR_DB_CLIENT: 1148 psError(PXTOOLS_ERR_SYS, false, "database error"); 1149 case PS_ERR_DB_SERVER: 1150 psError(PXTOOLS_ERR_PROG, false, "database error"); 1151 default: 1152 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1153 } 1154 1155 return false; 1156 } 1157 if (!psArrayLength(output)) { 1158 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 1159 psFree(output); 1160 return true; 1161 } 1162 1163 if (psArrayLength(output)) { 1164 // negative simple so the default is true 1165 if (!ippdbPrintMetadatas(stdout, output, "tocleanup", !simple)) { 1166 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1167 psFree(output); 1168 return false; 1169 } 1170 } 1171 1172 psFree(output); 1173 1174 return true; 1175 } -
branches/eam_branches/20090820/ippTools/src/magicdstool.h
r25766 r25870 26 26 MAGICDSTOOL_MODE_NONE = 0x0, 27 27 MAGICDSTOOL_MODE_DEFINEBYQUERY, 28 MAGICDSTOOL_MODE_DEFINERUN,29 28 MAGICDSTOOL_MODE_UPDATERUN, 30 29 MAGICDSTOOL_MODE_TODESTREAK, … … 36 35 MAGICDSTOOL_MODE_TOREVERT, 37 36 MAGICDSTOOL_MODE_COMPLETEDREVERT, 37 MAGICDSTOOL_MODE_TOCLEANUP, 38 38 } MAGICDStoolMode; 39 39 -
branches/eam_branches/20090820/ippTools/src/magicdstoolConfig.c
r25766 r25870 54 54 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-noreplace", 0, "do not replace input files with the destreaked versions", false); 55 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data_group", NULL); 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 56 58 57 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by magicRun.label", NULL); … … 69 71 psMetadataAddU64(definebyqueryArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 70 72 71 // -definerun72 psMetadata *definerunArgs = psMetadataAlloc();73 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-magic_id", 0, "define magic_id (required)", 0);74 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-stage", 0, "define stage for run (required)", NULL);75 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-outroot", 0, "define output directory (required)", NULL);76 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-recoveryroot", 0, "define recovery directory", NULL);77 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-noreplace", 0, "do not replace the input wit with the destreaked versions", false);78 // psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-remove", 0, "use the simple output format", false);79 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL);80 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);81 82 73 // -updaterun 83 74 psMetadata *updaterunArgs = psMetadataAlloc(); 84 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magictool ID (required)", 0); 85 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state (required)", NULL); 76 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magictool ID", 0); 77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-stage", 0, "define stage", NULL); 78 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id", 0); 79 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 80 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-noreplace", 0, "only update runs with replace not set", false); 86 81 87 82 // -addinputskyfile … … 153 148 psMetadataAddU64(advancerunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 154 149 150 // -tocleanup 151 psMetadata *tocleanupArgs = psMetadataAlloc(); 152 psMetadataAddS64(tocleanupArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0); 153 psMetadataAddS64(tocleanupArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0); 154 psMetadataAddStr(tocleanupArgs, PS_LIST_TAIL, "-stage", 0, "define output directory", NULL); 155 psMetadataAddStr(tocleanupArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL); 156 psMetadataAddU64(tocleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 157 psMetadataAddBool(tocleanupArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 155 158 psFree(now); 156 159 … … 160 163 PXOPT_ADD_MODE("-definebyquery", "create magic de-streak runs from magic runs", 161 164 MAGICDSTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 162 PXOPT_ADD_MODE("-definerun", "create one magic de-streak run for one magic run",163 MAGICDSTOOL_MODE_DEFINERUN, definerunArgs);164 165 PXOPT_ADD_MODE("-updaterun", "update state of magic de-streak run", 165 166 MAGICDSTOOL_MODE_UPDATERUN, updaterunArgs); … … 181 182 PXOPT_ADD_MODE("-completedrevert", "change state for runs that have finished reverting", 182 183 MAGICDSTOOL_MODE_COMPLETEDREVERT, completedrevertArgs); 184 PXOPT_ADD_MODE("-tocleanup", "destreak runs to clean up", 185 MAGICDSTOOL_MODE_TOCLEANUP, tocleanupArgs); 183 186 184 187 -
branches/eam_branches/20090820/ippTools/src/magictool.c
r25766 r25870 117 117 // Optional 118 118 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 119 PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", false, false); 120 PXOPT_LOOKUP_STR(note, config->args, "-note", false, false); 119 121 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 120 122 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); … … 236 238 237 239 // create a new magicRun for this group 238 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, inverse, "new", workdir, "dirty", label, 239 dvodb, registered, 0); 240 magicRunRow *run = magicRunRowAlloc(0, 241 exp_id, 242 diff_id, 243 inverse, 244 "new", // state 245 workdir, 246 "dirty", // workdir_state 247 label, 248 data_group ? data_group : label, 249 dvodb, 250 registered, 251 0, // fault 252 note); 240 253 if (!run) { 241 254 psAbort("failed to alloc magicRun object"); … … 331 344 "dirty", // workdir_state 332 345 label, 346 NULL, // data_group 333 347 dvodb, 334 348 registered, 335 0 349 0, // fault 350 NULL 336 351 ); 337 352 … … 1449 1464 // Now queue any destreaked files to be re-verted 1450 1465 1451 // note: on failure magicRestoreStage issues the rollback1452 if (! magicRestoreStage(config, "raw", whereClause, "goto_censored")) {1466 // note: on failure pxmagicRestoreStage issues the rollback 1467 if (!pxmagicRestoreStage(config, "raw", whereClause, "goto_censored")) { 1453 1468 psFree(whereClause); 1454 1469 return false; 1455 1470 } 1456 if (! magicRestoreStage(config, "chip", whereClause, "goto_censored")) {1471 if (!pxmagicRestoreStage(config, "chip", whereClause, "goto_censored")) { 1457 1472 psFree(whereClause); 1458 1473 return false; 1459 1474 } 1460 if (! magicRestoreStage(config, "camera", whereClause, "goto_censored")) {1475 if (!pxmagicRestoreStage(config, "camera", whereClause, "goto_censored")) { 1461 1476 psFree(whereClause); 1462 1477 return false; 1463 1478 } 1464 if (! magicRestoreStage(config, "warp", whereClause, "goto_censored")) {1479 if (!pxmagicRestoreStage(config, "warp", whereClause, "goto_censored")) { 1465 1480 psFree(whereClause); 1466 1481 return false; 1467 1482 } 1468 if (! magicRestoreStage(config, "diff", whereClause, "goto_censored")) {1483 if (!pxmagicRestoreStage(config, "diff", whereClause, "goto_censored")) { 1469 1484 psFree(whereClause); 1470 1485 return false; -
branches/eam_branches/20090820/ippTools/src/pstamptool.c
r25766 r25870 48 48 static bool projectMode(pxConfig *config); 49 49 static bool modprojectMode(pxConfig *config); 50 static bool getdependentMode(pxConfig *config); 51 static bool pendingdependentMode(pxConfig *config); 52 static bool updatedependentMode(pxConfig *config); 50 53 51 54 # define MODECASE(caseName, func) \ … … 85 88 MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode); 86 89 MODECASE(PSTAMPTOOL_MODE_PROJECT, projectMode); 90 MODECASE(PSTAMPTOOL_MODE_GETDEPENDENT, getdependentMode); 91 MODECASE(PSTAMPTOOL_MODE_PENDINGDEPENDENT, pendingdependentMode); 92 MODECASE(PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentMode); 87 93 default: 88 94 psAbort("invalid option (this should not happen)"); … … 545 551 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 546 552 PXOPT_LOOKUP_S64(options, config->args, "-options", false, false); 553 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", false, false); 547 554 548 555 // unless the job is being inserted with stop state require outputBase … … 570 577 exp_id, 571 578 outputBase, 572 options 579 options, 580 dep_id 573 581 )) { 574 582 psError(PS_ERR_UNKNOWN, false, "database error"); … … 896 904 } 897 905 906 static bool getdependentMode(pxConfig *config) 907 { 908 PS_ASSERT_PTR_NON_NULL(config, false); 909 910 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 911 PXOPT_LOOKUP_S64(stage_id, config->args, "-stage_id", true, false); 912 PXOPT_LOOKUP_STR(imagedb, config->args, "-imagedb", true, false); 913 PXOPT_LOOKUP_STR(rlabel, config->args, "-rlabel", false, false); 914 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 915 PXOPT_LOOKUP_BOOL(no_create, config->args, "-no_create", false); 916 917 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 918 if (!query) { 919 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 920 return false; 921 } 922 if (!p_psDBRunQuery(config->dbh, query)) { 923 psError(PS_ERR_UNKNOWN, false, "database error"); 924 psFree(query); 925 return false; 926 } 927 psFree(query); 928 929 psArray *output = p_psDBFetchResult(config->dbh); 930 if (!output) { 931 psError(PS_ERR_UNKNOWN, false, "database error"); 932 return false; 933 } 934 if (psArrayLength(output)) { 935 psMetadata *dep = output->data[0]; 936 psS64 dep_id = psMetadataLookupS64(NULL, dep, "dep_id"); 937 if (!dep_id) { 938 psError(PS_ERR_UNKNOWN, false, "database error"); 939 return false; 940 } 941 printf("%" PRId64 "\n", dep_id); 942 return true; 943 } 944 if (no_create) { 945 return true; 946 } 947 // no existing dependent that matches, insert one 948 949 if (!pstampDependentInsert( 950 config->dbh, 951 0, // dep_id 952 "new", // state 953 stage, 954 stage_id, 955 imagedb, 956 rlabel, 957 no_magic 958 )) { 959 psError(PS_ERR_UNKNOWN, false, "failed to insert pstampDependent"); 960 return false; 961 } 962 963 psS64 dep_id = psDBLastInsertID(config->dbh); 964 965 printf("%" PRId64 "\n", dep_id); 966 967 return true; 968 } 969 970 static bool pendingdependentMode(pxConfig *config) 971 { 972 PS_ASSERT_PTR_NON_NULL(config, false); 973 974 psMetadata *where = psMetadataAlloc(); 975 976 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 977 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 978 979 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 980 if (!query) { 981 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 982 return false; 983 } 984 985 if (psListLength(where->list)) { 986 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampDependent"); 987 psStringAppend(&query, " AND %s", whereClause); 988 psFree(whereClause); 989 } 990 psFree(where); 991 992 // treat limit == 0 as "no limit" 993 if (limit) { 994 psString limitString = psDBGenerateLimitSQL(limit); 995 psStringAppend(&query, " %s", limitString); 996 psFree(limitString); 997 } 998 999 if (!p_psDBRunQuery(config->dbh, query)) { 1000 psError(PS_ERR_UNKNOWN, false, "database error"); 1001 psFree(query); 1002 return false; 1003 } 1004 psFree(query); 1005 1006 psArray *output = p_psDBFetchResult(config->dbh); 1007 if (!output) { 1008 psError(PS_ERR_UNKNOWN, false, "database error"); 1009 return false; 1010 } 1011 if (!psArrayLength(output)) { 1012 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 1013 psFree(output); 1014 return true; 1015 } 1016 1017 // negative simple so the default is true 1018 if (!ippdbPrintMetadatas(stdout, output, "pstampDependent", !simple)) { 1019 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1020 psFree(output); 1021 return false; 1022 } 1023 1024 psFree(output); 1025 1026 return true; 1027 } 1028 static bool updatedependentMode(pxConfig *config) 1029 { 1030 PS_ASSERT_PTR_NON_NULL(config, false); 1031 1032 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", true, false); 1033 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 1034 1035 char *query ="UPDATE pstampDependent" 1036 " SET state = '%s'" 1037 " WHERE dep_id = %" PRId64; 1038 1039 if (!p_psDBRunQueryF(config->dbh, query, state, dep_id)) { 1040 psError(PS_ERR_UNKNOWN, false, "database error"); 1041 psFree(query); 1042 return false; 1043 } 1044 1045 psU64 affected = psDBAffectedRows(config->dbh); 1046 if (affected != 1) { 1047 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 1048 PRIu64 " rows were modified", affected); 1049 return false; 1050 } 1051 1052 return true; 1053 } -
branches/eam_branches/20090820/ippTools/src/pstamptool.h
r25766 r25870 43 43 PSTAMPTOOL_MODE_MODPROJECT, 44 44 PSTAMPTOOL_MODE_PROJECT, 45 PSTAMPTOOL_MODE_GETDEPENDENT, 46 PSTAMPTOOL_MODE_PENDINGDEPENDENT, 47 PSTAMPTOOL_MODE_UPDATEDEPENDENT, 45 48 } pstamptoolMode; 46 49 -
branches/eam_branches/20090820/ippTools/src/pstamptoolConfig.c
r25766 r25870 112 112 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-exp_id", 0, "define exposure id", 0); 113 113 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-options", 0, "define options", 0); 114 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-dep_id", 0, "define job dep_id", 0); 114 115 psMetadataAddS16(addjobArgs, PS_LIST_TAIL, "-fault", 0, "define job result", 0); 115 116 … … 143 144 psMetadataAddBool(revertjobArgs, PS_LIST_TAIL, "-all", 0, "revert all faulted jobs", false); 144 145 psMetadataAddU64(revertjobArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 146 147 // -getdependent 148 psMetadata *getdependentArgs = psMetadataAlloc(); 149 psMetadataAddS64(getdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define id for dependent run (required)", 0); 150 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-stage", 0, "define stage for dependent run (required)", NULL); 151 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-imagedb", 0, "define imagedb for depenent run (required)", NULL); 152 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-rlabel", 0, "define label for dependent run", NULL); 153 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_magic", 0, "define no_magic", false); 154 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no run exists do not create one", false); 155 156 // -updatedependent 157 psMetadata *updatedependentArgs = psMetadataAlloc(); 158 psMetadataAddS64(updatedependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define id for dependent run (required)", 0); 159 psMetadataAddStr(updatedependentArgs, PS_LIST_TAIL, "-set_state", 0, "new value for state (required)", NULL); 160 161 // -pendingdependent 162 psMetadata *pendingdependentArgs = psMetadataAlloc(); 163 psMetadataAddS64(pendingdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define id for dependent run", 0); 164 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-stage", 0, "define stage for dependent run", NULL); 165 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-imagedb", 0, "define imagedb for depenent run", NULL); 166 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-rlabel", 0, "define label for dependent run", NULL); 167 psMetadataAddBool(pendingdependentArgs,PS_LIST_TAIL, "-no_magic", 0, "define no_magic", false); 168 psMetadataAddBool(pendingdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no run exists do not create one", false); 169 psMetadataAddU64(pendingdependentArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 170 psMetadataAddBool(pendingdependentArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 145 171 146 172 // -addproject … … 189 215 PXOPT_ADD_MODE("-moddatastore", "", PSTAMPTOOL_MODE_MODDATASTORE, moddatastoreArgs); 190 216 217 PXOPT_ADD_MODE("-getdependent", "", PSTAMPTOOL_MODE_GETDEPENDENT, getdependentArgs); 218 PXOPT_ADD_MODE("-updatedependent", "", PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentArgs); 219 PXOPT_ADD_MODE("-pendingdependent","", PSTAMPTOOL_MODE_PENDINGDEPENDENT, pendingdependentArgs); 220 191 221 PXOPT_ADD_MODE("-addproject", "", PSTAMPTOOL_MODE_ADDPROJECT, addprojectArgs); 192 222 PXOPT_ADD_MODE("-modproject", "", PSTAMPTOOL_MODE_MODPROJECT, modprojectArgs); -
branches/eam_branches/20090820/ippTools/src/pxadd.c
r25766 r25870 29 29 #include "pxadd.h" 30 30 31 bool pxaddSetSearchArgs (psMetadata *md) { 32 33 psMetadataAddS64(md, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 34 psMetadataAddS64(md, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 35 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, "-comment", 0, "search by comment", NULL); */ 44 /* psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); */ 45 /* psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); */ 46 /* psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); */ 47 /* psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); */ 48 /* psMetadataAddF64(md, PS_LIST_TAIL, "-ra_min", 0, "define min RA (degrees) ", NAN); */ 49 /* psMetadataAddF64(md, PS_LIST_TAIL, "-ra_max", 0, "define max RA (degrees) ", NAN); */ 50 /* psMetadataAddF64(md, PS_LIST_TAIL, "-decl_min", 0, "define min DEC (degrees)", NAN); */ 51 /* psMetadataAddF64(md, PS_LIST_TAIL, "-decl_max", 0, "define max DEC (degrees)", NAN); */ 52 /* psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_min", 0, "define min exposure time", NAN); */ 53 /* psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_max", 0, "define max exposure time", NAN); */ 54 /* psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); */ 55 /* psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define max fraction of saturated pixels", NAN); */ 56 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_min", 0, "define min background", NAN); */ 57 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_max", 0, "define max background", NAN); */ 58 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_min", 0, "define min background standard deviation", NAN); */ 59 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max background standard deviation", NAN); */ 60 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define min background mean standard deviation (across imfiles)", NAN); */ 61 /* psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max background mean standard deviation (across imfiles)", NAN); */ 62 /* psMetadataAddF64(md, PS_LIST_TAIL, "-alt_min", 0, "define min altitude", NAN); */ 63 /* psMetadataAddF64(md, PS_LIST_TAIL, "-alt_max", 0, "define max altitude", NAN); */ 64 /* psMetadataAddF64(md, PS_LIST_TAIL, "-az_min", 0, "define min azimuth ", NAN); */ 65 /* psMetadataAddF64(md, PS_LIST_TAIL, "-az_max", 0, "define max azimuth ", NAN); */ 66 /* psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); */ 67 /* psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); */ 68 /* psMetadataAddF64(md, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); */ 69 /* psMetadataAddF64(md, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); */ 70 /* psMetadataAddStr(md, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); */ 71 /* psMetadataAddF32(md, PS_LIST_TAIL, "-sun_angle_min", 0, "define min solar angle", NAN); */ 72 /* psMetadataAddF32(md, PS_LIST_TAIL, "-sun_angle_max", 0, "define max solar angle", NAN); */ 73 74 return true; 75 } 76 77 bool pxaddGetSearchArgs (pxConfig *config, psMetadata *where) { 78 79 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 80 /* PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); */ 81 /* PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); */ 82 /* PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); */ 83 /* PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); */ 84 /* PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); */ 85 /* PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); */ 86 /* PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); */ 87 /* PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); */ 88 /* PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); */ 89 /* PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); */ 90 /* PXOPT_COPY_STR(config->args, where, "-comment", "rawExp.comment", "LIKE"); */ 91 /* PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); */ 92 /* PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); */ 93 /* PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">="); */ 94 /* PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<"); */ 95 /* PXOPT_COPY_RADEC(config->args, where, "-ra_min", "rawExp.ra", ">="); */ 96 /* PXOPT_COPY_RADEC(config->args, where, "-ra_max", "rawExp.ra", "<"); */ 97 /* PXOPT_COPY_RADEC(config->args, where, "-decl_min", "rawExp.decl", ">="); */ 98 /* PXOPT_COPY_RADEC(config->args, where, "-decl_max", "rawExp.decl", "<"); */ 99 /* PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); */ 100 /* PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); */ 101 /* PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); */ 102 /* PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); */ 103 /* PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); */ 104 /* PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); */ 105 /* PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); */ 106 /* PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); */ 107 /* PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); */ 108 /* PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); */ 109 /* PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); */ 110 /* PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); */ 111 /* PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); */ 112 /* PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); */ 113 /* PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); */ 114 /* PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); */ 115 /* PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); */ 116 /* PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); */ 117 /* PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); */ 118 /* PXOPT_COPY_F32(config->args, where, "-sun_angle_min", "rawExp.sun_angle", ">="); */ 119 /* PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "rawExp.sun_angle", "<"); */ 120 121 return true; 122 } 123 124 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state, psS64 magicked) 31 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state) 125 32 { 126 33 PS_ASSERT_PTR_NON_NULL(config, false); … … 134 41 } 135 42 136 char *query = "UPDATE addRun SET state = '%s', magicked = %" PRId64 " WHERE add_id = %" PRId64; 137 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, add_id)) { 138 psError(PS_ERR_UNKNOWN, false, 139 "failed to change state for add_id %" PRId64, add_id); 43 char *query = "UPDATE addRun SET state = '%s' WHERE add_id = %" PRId64; 44 if (!p_psDBRunQueryF(config->dbh, query, state, add_id)) { 45 psError(PS_ERR_UNKNOWN, false, "failed to change state for add_id %" PRId64, add_id); 140 46 return false; 141 47 } … … 216 122 } 217 123 218 // Need to think more about this to see what we want it to do. BROKEN219 124 bool pxaddQueueByCamID(pxConfig *config, 220 125 psS64 cam_id, 221 126 char *workdir, 127 char *reduction, 222 128 char *label, 223 char *recipe, 224 char *dvodb) 129 char *data_group, 130 char *dvodb, 131 char *note, 132 bool image_only) 225 133 { 226 134 PS_ASSERT_PTR_NON_NULL(config, false); … … 236 144 } 237 145 } 238 // fprintf(stderr,"%s",query); 146 239 147 // queue the exp 240 // XXX chip_id is being cast here work around psS64 have a different type241 // differenton 32/64148 // Note: cam_id is being cast here work around psS64 have a different type different 149 // on 32/64 242 150 if (!p_psDBRunQueryF(config->dbh, query, 243 151 "new", // state 244 workdir ? workdir : "NULL",152 workdir ? workdir : "NULL", 245 153 "dirty", //workdir_state 246 label ? label : "NULL", 247 dvodb ? dvodb : "NULL", 248 (long long)cam_id 154 reduction? reduction : "NULL", 155 label ? label : "NULL", 156 data_group ? data_group : "NULL", 157 dvodb ? dvodb : "NULL", 158 note ? note : "NULL", 159 image_only, 160 (long long) cam_id 249 161 )) { 250 162 psError(PS_ERR_UNKNOWN, false, "database error"); -
branches/eam_branches/20090820/ippTools/src/pxadd.h
r25766 r25870 25 25 #include "pxtools.h" 26 26 27 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state , psS64 magicked);27 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state); 28 28 bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 29 bool pxaddRunSetLabel(pxConfig *config, psS64 add_id, const char *label); 30 30 bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label); 31 31 32 bool pxaddSetSearchArgs (psMetadata *md);33 bool pxaddGetSearchArgs (pxConfig *config, psMetadata *where);34 35 // Likely BROKEN36 32 bool pxaddQueueByCamID(pxConfig *config, 37 psS64 cam_id, 38 char *workdir, 39 char *label, 40 char *recipe, 41 char *dvodb); 42 33 psS64 cam_id, 34 char *workdir, 35 char *reduction, 36 char *label, 37 char *data_group, 38 char *dvodb, 39 char *note, 40 bool image_only); 43 41 44 42 #endif // PXADD_H -
branches/eam_branches/20090820/ippTools/src/pxadmin.c
r23310 r25870 2 2 * pxadmin.c 3 3 * 4 * Copyright (C) 2006-200 8Joshua Hoblitt4 * Copyright (C) 2006-2009 Joshua Hoblitt 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it … … 31 31 bool createMirrorMode(pxConfig *config); 32 32 bool deleteMode(pxConfig *config); 33 static bool insert_dbversion(pxConfig * config, const char *versionString); 33 34 static bool runMultipleStatments(pxConfig *config, const char *query); 34 35 … … 113 114 psFree(query); 114 115 116 if (!insert_dbversion(config, PACKAGE_VERSION)) { 117 psError(PS_ERR_UNKNOWN, false, "failed to set database version"); 118 return false; 119 } 120 115 121 // COMMIT 116 122 if (!psDBCommit(config->dbh)) { … … 148 154 } 149 155 psFree(query); 156 157 if (!insert_dbversion(config, PACKAGE_VERSION)) { 158 psError(PS_ERR_UNKNOWN, false, "failed to set database version"); 159 return false; 160 } 150 161 151 162 // COMMIT … … 262 273 return true; 263 274 } 275 276 #ifdef notdef 277 static bool update_dbversion(pxConfig * config, const char *versionString) 278 { 279 psString query = pxDataGet("pxadmin_update_version.sql"); 280 if (!query) { 281 psError(PS_ERR_UNKNOWN, false, "failed to retrieve SQL statement"); 282 psFree(query); 283 return false; 284 } 285 if (!p_psDBRunQueryF(config->dbh, query, versionString)) { 286 psError(PS_ERR_UNKNOWN, false, "database error"); 287 psFree(query); 288 return false; 289 } 290 return true; 291 } 292 #endif 293 static bool insert_dbversion(pxConfig * config, const char *versionString) 294 { 295 psString query = "INSERT INTO dbversion VALUES('%s', CURRENT_TIMESTAMP())"; 296 if (!query) { 297 psError(PS_ERR_UNKNOWN, false, "failed to retrieve SQL statement"); 298 psFree(query); 299 return false; 300 } 301 if (!p_psDBRunQueryF(config->dbh, query, versionString)) { 302 psError(PS_ERR_UNKNOWN, false, "database error"); 303 psFree(query); 304 return false; 305 } 306 return true; 307 } -
branches/eam_branches/20090820/ippTools/src/pxcam.c
r24866 r25870 141 141 } 142 142 143 144 bool pxcamRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)145 {146 PS_ASSERT_PTR_NON_NULL(config, false);147 PS_ASSERT_PTR_NON_NULL(state, false);148 149 // check that state is a valid string value150 if (!pxIsValidState(state)) {151 psError(PS_ERR_UNKNOWN, false,152 "invalid chipRun state: %s", state);153 return false;154 }155 156 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET camRun.state = '%s'");157 158 if (where) {159 psString whereClause = psDBGenerateWhereSQL(where, NULL);160 psStringAppend(&query, " %s", whereClause);161 psFree(whereClause);162 }163 164 if (!p_psDBRunQueryF(config->dbh, query, state)) {165 psFree(query);166 psError(PS_ERR_UNKNOWN, false, "database error");167 return false;168 }169 170 psFree(query);171 172 return true;173 }174 175 176 bool pxcamRunSetLabel(pxConfig *config, psS64 cam_id, const char *label)177 {178 PS_ASSERT_PTR_NON_NULL(config, false);179 // note label == NULL should be explicitly allowed180 181 char *query = "UPDATE camRun SET camRun.label = '%s' WHERE cam_id = %" PRId64;182 if (!p_psDBRunQueryF(config->dbh, query, label, cam_id)) {183 psError(PS_ERR_UNKNOWN, false,184 "failed to change state for cam_id %" PRId64, cam_id);185 return false;186 }187 188 return true;189 }190 191 bool pxcamRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)192 {193 PS_ASSERT_PTR_NON_NULL(config, false);194 // note label == NULL should be explicitly allowed195 196 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET camRun.label = '%s'");197 198 if (where) {199 psString whereClause = psDBGenerateWhereSQL(where, NULL);200 psStringAppend(&query, " %s", whereClause);201 psFree(whereClause);202 }203 204 if (!p_psDBRunQueryF(config->dbh, query, label)) {205 psFree(query);206 psError(PS_ERR_UNKNOWN, false, "database error");207 return false;208 }209 210 psFree(query);211 212 return true;213 }214 215 216 143 bool pxcamQueueByChipID(pxConfig *config, 217 144 psS64 chip_id, 218 145 char *workdir, 219 146 char *label, 147 char *data_group, 148 char *dist_group, 220 149 char *recipe, 221 150 char *expgroup, 222 151 char *dvodb, 223 152 char *tess_id, 224 char *end_stage) 153 char *end_stage, 154 char *note) 225 155 { 226 156 PS_ASSERT_PTR_NON_NULL(config, false); … … 245 175 "dirty", //workdir_state 246 176 label ? label : "NULL", 177 data_group ? data_group : "NULL", 178 dist_group ? dist_group : "NULL", 247 179 recipe ? recipe : "NULL", 248 180 expgroup ? expgroup : "NULL", … … 250 182 tess_id ? tess_id : "NULL", 251 183 end_stage ? end_stage : "NULL", 184 note ? note : "NULL", 252 185 (long long)chip_id 253 186 )) { -
branches/eam_branches/20090820/ippTools/src/pxcam.h
r24681 r25870 26 26 27 27 bool pxcamRunSetState(pxConfig *config, psS64 cam_id, const char *state, psS64 magicked); 28 bool pxcamRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state);29 bool pxcamRunSetLabel(pxConfig *config, psS64 cam_id, const char *label);30 bool pxcamRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label);31 32 28 bool pxcamSetSearchArgs (psMetadata *md); 33 29 bool pxcamGetSearchArgs (pxConfig *config, psMetadata *where); … … 37 33 char *workdir, 38 34 char *label, 35 char *data_group, 36 char *dist_group, 39 37 char *recipe, 40 38 char *expgroup, 41 39 char *dvodb, 42 40 char *tess_id, 43 char *end_stage); 41 char *end_stage, 42 char *note); 44 43 45 44 #endif // PXCAM_H -
branches/eam_branches/20090820/ippTools/src/pxchip.c
r24866 r25870 192 192 } 193 193 194 195 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label) 194 bool pxchipProcessedImfileSetStateByQuery(pxConfig *config, psMetadata *where, const char *state) 196 195 { 197 196 PS_ASSERT_PTR_NON_NULL(config, false); 198 // note label == NULL should be explicitly allowed199 200 char *query = "UPDATE chipRun SET label = '%s' WHERE chip_id = %" PRId64;201 if (!p _psDBRunQueryF(config->dbh, query, label, chip_id)) {202 psError(PS_ERR_UNKNOWN, false, 203 "failed to change state for chip_id %" PRId64, chip_id);204 return false;205 } 206 207 return true; 208 } 209 210 211 bool pxchipRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label) 212 { 213 PS_ASSERT_PTR_NON_NULL(config, false); 214 // note label == NULL should be explicitly allowed 215 216 psString query = psStringCopy("UPDATE chip Run JOIN rawExp USING(exp_id) SET label= '%s'");197 PS_ASSERT_PTR_NON_NULL(state, false); 198 199 // check that state is a valid string value 200 if (!pxIsValidState(state)) { 201 psError(PS_ERR_UNKNOWN, false, "invalid chipProcessedImfile state: %s", state); 202 return false; 203 } 204 205 /* if (!strcmp(state, "full")) { */ 206 /* // There are states that need to be met for a run to be set to full that we don't */ 207 /* // check here. */ 208 /* // for example all of the run's Imfiles must have chipProcessedImfile.data_state == "full" */ 209 /* // chipRun.magicked = (SUM(!chipProcessedImfile.magicked) = 0) */ 210 /* // so don't do allow setting the state to full */ 211 /* psError(PS_ERR_UNKNOWN, true, "cannot use -updaterun so set chipRun state to full"); */ 212 /* return false; */ 213 /* } */ 214 215 psString query = psStringCopy("UPDATE chipProcessedImfile JOIN chipRun USING(chip_id) JOIN rawExp ON chipRun.exp_id = rawExp.exp_id SET state = '%s'"); 217 216 218 217 if (where && psListLength(where->list) > 0) { … … 222 221 } 223 222 224 if (!p_psDBRunQueryF(config->dbh, query, label)) {223 if (!p_psDBRunQueryF(config->dbh, query, state)) { 225 224 psFree(query); 226 225 psError(PS_ERR_UNKNOWN, false, "database error"); … … 232 231 return true; 233 232 } 234 235 233 236 234 psS64 pxchipQueueByExpTag(pxConfig *config, … … 238 236 const char *workdir, 239 237 const char *label, 238 const char *data_group, 239 const char *dist_group, 240 240 const char *reduction, 241 241 const char *expgroup, 242 242 const char *dvodb, 243 243 const char *tess_id, 244 const char *end_stage) 244 const char *end_stage, 245 const char *note) 245 246 { 246 247 PS_ASSERT_PTR_NON_NULL(config, false); … … 260 261 "dirty", // workdir_state 261 262 label, 263 data_group, 264 dist_group, 262 265 reduction, 263 266 expgroup, … … 265 268 tess_id, 266 269 end_stage, 267 0 // magicked 270 0, // magicked 271 note 268 272 ) 269 273 ) { -
branches/eam_branches/20090820/ippTools/src/pxchip.h
r23381 r25870 25 25 #include "pxtools.h" 26 26 27 28 27 29 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked); 28 bool pxchipRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label); 30 bool pxchipRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label); 30 bool pxchipProcessedImfileSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 31 31 32 32 psS64 pxchipQueueByExpTag(pxConfig *config, … … 34 34 const char *workdir, 35 35 const char *label, 36 const char *data_group, 37 const char *dist_group, 36 38 const char *reduction, 37 39 const char *expgroup, 38 40 const char *dvodb, 39 41 const char *tess_id, 40 const char *end_stage); 42 const char *end_stage, 43 const char *note); 41 44 42 45 -
branches/eam_branches/20090820/ippTools/src/pxfake.c
r21402 r25870 51 51 } 52 52 53 54 bool pxfakeRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)55 {56 PS_ASSERT_PTR_NON_NULL(config, false);57 PS_ASSERT_PTR_NON_NULL(state, false);58 59 // check that state is a valid string value60 if (!pxIsValidState(state)) {61 psError(PS_ERR_UNKNOWN, false,62 "invalid fakeRun state: %s", state);63 return false;64 }65 66 psString query = psStringCopy("UPDATE fakeRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET fakeRun.state = '%s'");67 68 if (where) {69 psString whereClause = psDBGenerateWhereSQL(where, NULL);70 psStringAppend(&query, " %s", whereClause);71 psFree(whereClause);72 }73 74 if (!p_psDBRunQueryF(config->dbh, query, state)) {75 psFree(query);76 psError(PS_ERR_UNKNOWN, false, "database error");77 return false;78 }79 80 psFree(query);81 82 return true;83 }84 85 86 bool pxfakeRunSetLabel(pxConfig *config, psS64 fake_id, const char *label)87 {88 PS_ASSERT_PTR_NON_NULL(config, false);89 // note label == NULL should be explicitly allowed90 91 char *query = "UPDATE fakeRun SET fakeRun.label = '%s' WHERE fake_id = %" PRId64;92 if (!p_psDBRunQueryF(config->dbh, query, label, fake_id)) {93 psError(PS_ERR_UNKNOWN, false,94 "failed to change state for fake_id %" PRId64, fake_id);95 return false;96 }97 98 return true;99 }100 101 102 bool pxfakeRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)103 {104 PS_ASSERT_PTR_NON_NULL(config, false);105 // note label == NULL should be explicitly allowed106 107 psString query = psStringCopy("UPDATE fakeRun JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET fakeRun.label = '%s'");108 109 if (where) {110 psString whereClause = psDBGenerateWhereSQL(where, NULL);111 psStringAppend(&query, " %s", whereClause);112 psFree(whereClause);113 }114 115 if (!p_psDBRunQueryF(config->dbh, query, label)) {116 psFree(query);117 psError(PS_ERR_UNKNOWN, false, "database error");118 return false;119 }120 121 psFree(query);122 123 return true;124 }125 126 127 53 psS64 pxfakeQueueByCamID(pxConfig *config, 128 54 psS64 cam_id, 129 55 char *workdir, 130 56 char *label, 57 char *data_group, 58 char *dist_group, 131 59 char *reduction, 132 60 char *expgroup, 133 61 char *dvodb, 134 62 char *tess_id, 135 char *end_stage) 63 char *end_stage, 64 char *note) 136 65 { 137 66 PS_ASSERT_PTR_NON_NULL(config, false); … … 157 86 workdir ? workdir : "NULL", 158 87 label ? label : "NULL", 88 data_group ? data_group : "NULL", 89 dist_group ? dist_group : "NULL", 159 90 reduction? reduction: "NULL", 160 91 expgroup ? expgroup : "NULL", … … 162 93 tess_id ? tess_id : "NULL", 163 94 end_stage ? end_stage : "NULL", 95 note ? note : "NULL", 164 96 (long long)cam_id 165 97 )) { -
branches/eam_branches/20090820/ippTools/src/pxfake.h
r17938 r25870 26 26 27 27 bool pxfakeRunSetState(pxConfig *config, psS64 fake_id, const char *state); 28 bool pxfakeRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state);29 bool pxfakeRunSetLabel(pxConfig *config, psS64 fake_id, const char *label);30 bool pxfakeRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label);31 32 28 33 29 psS64 pxfakeQueueByCamID(pxConfig *config, … … 35 31 char *workdir, 36 32 char *label, 33 char *data_group, 34 char *dist_group, 37 35 char *reduction, 38 36 char *expgroup, 39 37 char *dvodb, 40 38 char *tess_id, 41 char *end_stage); 39 char *end_stage, 40 char *note); 42 41 43 42 -
branches/eam_branches/20090820/ippTools/src/pxmagic.c
r25766 r25870 29 29 #include "pxmagic.h" 30 30 31 bool magicRestoreStage(pxConfig *config, psString stage, psString whereClause, psString newState)31 bool pxmagicRestoreStage(pxConfig *config, psString stage, psString whereClause, psString newState) 32 32 { 33 33 psString queryFile = NULL; … … 66 66 return true; 67 67 } 68 69 bool pxmagicAddWhere(pxConfig *config, psString *out, psString table) 70 { 71 PXOPT_LOOKUP_U64(magicked, config->args, "-magicked", false, false); 72 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false); 73 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false); 74 75 if (not_destreaked) { 76 if (destreaked) { 77 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense"); 78 return false; 79 } 80 if (magicked) { 81 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense"); 82 return false; 83 } 84 psStringAppend(out, " AND %s.magicked = 0", table); 85 } 86 if (destreaked) { 87 psStringAppend(out, " AND %s.magicked != 0", table); 88 } 89 return true; 90 } 91 92 void pxmagicAddArguments(psMetadata *md) 93 { 94 psMetadataAddBool(md, PS_LIST_TAIL, "-destreaked", 0, "search for destreaked images", false); 95 psMetadataAddBool(md, PS_LIST_TAIL, "-not_destreaked", 0, "search for images that have not been destreaked", false); 96 psMetadataAddS64(md, PS_LIST_TAIL, "-magicked", 0, "search by magicked value", 0); 97 } -
branches/eam_branches/20090820/ippTools/src/pxmagic.h
r25766 r25870 25 25 #include "pxtools.h" 26 26 27 extern bool magicRestoreStage(pxConfig *config, psString stage, psString whereClause, psString newState); 27 extern bool pxmagicRestoreStage(pxConfig *config, psString stage, psString whereClause, psString newState); 28 29 extern bool pxmagicAddWhere(pxConfig *config, psString *string, psString table); 30 extern void pxmagicAddArguments(psMetadata *md); 28 31 29 32 #endif // PXMAGIC_H -
branches/eam_branches/20090820/ippTools/src/pxtools.c
r25766 r25870 108 108 return true; 109 109 } 110 111 // shared code for updating the various strings for a Run 112 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString table, bool has_dist_group) 113 { 114 PS_ASSERT_PTR_NON_NULL(config, false); 115 PS_ASSERT_PTR_NON_NULL(where, false); 116 PS_ASSERT_PTR_NON_NULL(pQuery, false); 117 PS_ASSERT_PTR_NON_NULL(*pQuery, false); 118 119 // make sure that -state is not the only selection parameter 120 PXOPT_LOOKUP_STR(where_state, config->args, "-state", false, false); 121 if (where_state && (psListLength(where->list) < 2)) { 122 psError(PXTOOLS_ERR_DATA, true, "selection by -state alone is not allowed"); 123 return false; 124 } 125 126 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 127 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 128 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 129 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 130 131 psString dist_group = NULL; 132 if (has_dist_group) { 133 PXOPT_LOOKUP_STR(tmp_dist_group, config->args, "-set_dist_group", false, false); 134 dist_group = tmp_dist_group; 135 } 136 137 if ((!state) && (!label) && (!data_group) && (has_dist_group && !dist_group) && !(note)) { 138 psError(PXTOOLS_ERR_DATA, false, "parameters are required"); 139 return false; 140 } 141 142 if (state && ! pxIsValidState(state)) { 143 psError(PXTOOLS_ERR_DATA, false, "pxIsValidState failed"); 144 return false; 145 } 146 147 // first paramter is added with "SET param = 'value'" 148 // subseqent ones with ", param = 'value'" 149 char *separator = " SET "; 150 char *comma = ","; 151 152 # define addColumn(_tab, _val) \ 153 do { \ 154 if (_val) { \ 155 psStringAppend(pQuery, "%s %s.%s = '%s'", separator, _tab, #_val, _val); \ 156 separator = comma; \ 157 } \ 158 } while (0) 159 160 addColumn(table, state); 161 addColumn(table, data_group); 162 if (has_dist_group) { 163 addColumn(table, dist_group); 164 } 165 addColumn(table, note); 166 addColumn(table, label); 167 168 psString whereClause = psDBGenerateWhereSQL(where, NULL); 169 psStringAppend(pQuery, " %s", whereClause); 170 psFree(whereClause); 171 172 if (!p_psDBRunQuery(config->dbh, *pQuery)) { 173 psError(PS_ERR_UNKNOWN, false, "database error"); 174 return false; 175 } 176 177 return true; 178 } 179 180 bool pxLookupVersion(pxConfig *config, psArray **pArray) 181 { 182 const char *query = "SELECT * FROM dbversion"; 183 184 if (!p_psDBRunQuery(config->dbh, query)) { 185 psError(PS_ERR_UNKNOWN, false, "database error"); 186 return false; 187 } 188 189 psArray *output = p_psDBFetchResult(config->dbh); 190 if (!output) { 191 psError(PS_ERR_UNKNOWN, false, "database error"); 192 return false; 193 } 194 if (!psArrayLength(output)) { 195 psFree(output); 196 psError(PS_ERR_UNKNOWN, true, "no rows in dbversion"); 197 return false; 198 } 199 if (psArrayLength(output) > 1) { 200 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found in dbversion: %" PRId64, 201 psArrayLength(output)); 202 return false; 203 } 204 *pArray = output; 205 206 return true; 207 } 208 209 psString pxGetDBVersion(pxConfig *config) 210 { 211 PS_ASSERT_PTR_NON_NULL(config, NULL); 212 213 psArray *array = NULL; 214 if (!pxLookupVersion(config, &array)) { 215 psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed"); 216 return NULL; 217 } 218 psMetadata *md = array->data[0]; 219 if (!md) { 220 psError(PS_ERR_UNKNOWN, true, "output of pxLookupVersion is null"); 221 return NULL; 222 } 223 224 psString version = psMetadataLookupStr(NULL, md, "schema_version"); 225 226 return version; 227 } 228 229 bool pxExportVersion(pxConfig *config, FILE *file) 230 { 231 PS_ASSERT_PTR_NON_NULL(config, NULL); 232 PS_ASSERT_PTR_NON_NULL(file, NULL); 233 234 psArray *array = NULL; 235 if (!pxLookupVersion(config, &array) || !array) { 236 psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed"); 237 return false; 238 } 239 if (!ippdbPrintMetadatas(file, array, "dbversion", true)) { 240 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 241 psFree(array); 242 return false; 243 } 244 return true; 245 } 246 247 bool pxCheckImportVersion(pxConfig *config, psMetadata *input) 248 { 249 PS_ASSERT_PTR_NON_NULL(config, NULL); 250 PS_ASSERT_PTR_NON_NULL(input, NULL); 251 252 // This code was adapted from the way camtool parses the structures. 253 // Is this really the way to do it? 254 psMetadataItem *multi_item = psMetadataLookup(input, "dbversion"); 255 if (!multi_item || (multi_item->type != PS_DATA_METADATA_MULTI)) { 256 psError(PS_ERR_UNKNOWN, true, "dbversion multi not found in input"); 257 return false; 258 } 259 260 psMetadataItem *dbversion = psListGet(multi_item->data.list, 0); 261 if (!dbversion) { 262 psError(PS_ERR_UNKNOWN, true, "dbversion not found in input"); 263 return false; 264 } 265 266 if (!strcmp(dbversion->name, "dbversion")) { 267 // horray 268 psMetadata *md = dbversion->data.md; 269 psString schema_version = pxGetDBVersion(config); 270 if (!schema_version) { 271 psError(PS_ERR_UNKNOWN, false, "pxGetDBVersion failed"); 272 return false; 273 } 274 275 psString import_version = psMetadataLookupStr(NULL, md, "schema_version"); 276 if (import_version && strcmp(import_version, schema_version)) { 277 psError(PS_ERR_UNKNOWN, true, "input file schema_version: %s does not match data base: %s", 278 import_version, schema_version); 279 return false; 280 } else if (!import_version) { 281 psError(PS_ERR_UNKNOWN, true, "input file schema_version is NULL"); 282 return false; 283 } else { 284 // YIPPEE this file is the same version 285 } 286 } else { 287 psError(PS_ERR_UNKNOWN, true, "Unexpected config dump format"); 288 return false; 289 } 290 291 return true; 292 } -
branches/eam_branches/20090820/ippTools/src/pxtools.h
r25766 r25870 47 47 #include "pxtree.h" 48 48 #include "pxmagic.h" 49 #include "pxspace.h" 49 50 50 51 # define MAX_ROWS 10e9 … … 56 57 57 58 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code); 59 bool pxExportVersion(pxConfig *config, FILE *f); 60 bool pxCheckImportVersion(pxConfig *config, psMetadata *md); 58 61 59 62 psExit pxerrorGetExitStatus(void); … … 61 64 void pxUsage(FILE *stream, int argc, char **argv, const char *modeName, psMetadata *argSet); 62 65 bool pxGetOptions(FILE *stream, int argc, char **argv, pxConfig *config, psMetadata *modes, psMetadata *argSets); 66 67 bool pxUpdateRun(pxConfig *config, psMetadata *where, psString *pQuery, psString table, bool has_dist_group); 63 68 64 69 #define PXOPT_ADD_MODE(option, comment, modeval, argset) \ -
branches/eam_branches/20090820/ippTools/src/pxwarp.c
r24487 r25870 29 29 #include "pxwarp.h" 30 30 31 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state)32 {33 PS_ASSERT_PTR_NON_NULL(config, false);34 PS_ASSERT_PTR_NON_NULL(state, false);35 36 // check that state is a valid string value37 if (!pxIsValidState(state)) {38 psError(PS_ERR_UNKNOWN, false, "invalid warpRun state: %s", state);39 return false;40 }41 42 char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = %" PRId64;43 if (!p_psDBRunQueryF(config->dbh, query, state, warp_id)) {44 psError(PS_ERR_UNKNOWN, false,45 "failed to change state for warp_id %" PRId64, warp_id);46 return false;47 }48 49 return true;50 }51 52 53 bool pxwarpRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)54 {55 PS_ASSERT_PTR_NON_NULL(config, false);56 PS_ASSERT_PTR_NON_NULL(state, false);57 58 // check that state is a valid string value59 if (!pxIsValidState(state)) {60 psError(PS_ERR_UNKNOWN, false, "invalid warpRun state: %s", state);61 return false;62 }63 64 psString query = psStringCopy("UPDATE warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET warpRun.state = '%s'");65 66 if (where) {67 psString whereClause = psDBGenerateWhereSQL(where, NULL);68 if (whereClause && strlen(whereClause) > 0) {69 psStringAppend(&query, " %s", whereClause);70 }71 psFree(whereClause);72 }73 74 if (!p_psDBRunQueryF(config->dbh, query, state)) {75 psFree(query);76 psError(PS_ERR_UNKNOWN, false, "database error");77 return false;78 }79 80 psFree(query);81 82 return true;83 }84 85 86 bool pxwarpRunSetLabel(pxConfig *config, psS64 warp_id, const char *label)87 {88 PS_ASSERT_PTR_NON_NULL(config, false);89 // note label == NULL should be explicitly allowed90 91 char *query = "UPDATE warpRun SET warpRun.label = '%s' WHERE warp_id = %" PRId64;92 if (!p_psDBRunQueryF(config->dbh, query, label, warp_id)) {93 psError(PS_ERR_UNKNOWN, false,94 "failed to change label for warp_id %" PRId64, warp_id);95 return false;96 }97 98 return true;99 }100 101 102 bool pxwarpRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)103 {104 PS_ASSERT_PTR_NON_NULL(config, false);105 // note label == NULL should be explicitly allowed106 107 psString query = psStringCopy("UPDATE warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET warpRun.label = '%s'");108 109 if (where) {110 psString whereClause = psDBGenerateWhereSQL(where, NULL);111 psStringAppend(&query, " %s", whereClause);112 psFree(whereClause);113 }114 115 if (!p_psDBRunQueryF(config->dbh, query, label)) {116 psFree(query);117 psError(PS_ERR_UNKNOWN, false, "database error");118 return false;119 }120 121 psFree(query);122 123 return true;124 }125 126 127 31 bool pxwarpQueueByFakeID(pxConfig *config, 128 32 psS64 fake_id, 129 33 const char *workdir, 130 34 const char *label, 35 const char *data_group, 36 const char *dist_group, 131 37 const char *dvodb, 132 38 const char *tess_id, 133 39 const char *reduction, 134 const char *end_stage) 40 const char *end_stage, 41 const char *note) 135 42 { 136 43 PS_ASSERT_PTR_NON_NULL(config, false); … … 145 52 "dirty", // workdir_state 146 53 label, 54 data_group, 55 dist_group, 147 56 dvodb, 148 57 tess_id, 149 reduction,58 reduction, 150 59 end_stage, 151 60 NULL, // registered 152 0 // magicked zero when created will get updated when warpRun goes to 'full' 61 0, // magicked set to zero when created may get updated when warpRun goes to 'full' 62 NULL // note 153 63 )) { 154 64 psError(PS_ERR_UNKNOWN, false, "database error"); -
branches/eam_branches/20090820/ippTools/src/pxwarp.h
r24487 r25870 25 25 #include "pxtools.h" 26 26 27 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state);28 bool pxwarpRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state);29 bool pxwarpRunSetLabel(pxConfig *config, psS64 warp_id, const char *label);30 bool pxwarpRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label);31 32 27 bool pxwarpQueueByFakeID(pxConfig *config, 33 28 psS64 fake_id, 34 29 const char *workdir, 35 30 const char *label, 31 const char *data_group, 32 const char *dist_group, 36 33 const char *dvodb, 37 34 const char *tess_id, 38 35 const char *reduction, 39 const char *end_stage); 36 const char *end_stage, 37 const char *note); 40 38 41 39 #endif // PXWARP_H -
branches/eam_branches/20090820/ippTools/src/regtool.c
r25766 r25870 334 334 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 335 335 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 336 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 337 PXOPT_COPY_STR(config->args, where, "-obs_mode", "obs_mode", "=="); 336 338 PXOPT_COPY_S64(config->args, where, "-magicked", "magicked", "=="); 337 338 PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false);339 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);340 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false);341 339 342 340 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 343 341 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 344 342 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 343 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 345 344 PXOPT_LOOKUP_BOOL(ordered_by_date, config->args, "-ordered_by_date", false); 345 346 // build where string for some parameters that don't fit PXOPT_COPY* 347 psString where2 = NULL; 348 if (!pxmagicAddWhere(config, &where2, "rawImfile")) { 349 psError(PXTOOLS_ERR_DATA, false, "pxSpaceAddWhere failed"); 350 return false; 351 } 352 if (!pxspaceAddWhere(config, &where2, "rawImfile")) { 353 psError(PXTOOLS_ERR_DATA, false, "pxSpaceAddWhere failed"); 354 return false; 355 } 346 356 347 357 psString query = pxDataGet("regtool_processedimfile.sql"); … … 356 366 psStringAppend(&query, " AND %s", whereClause); 357 367 psFree(whereClause); 368 } else if (!all && !where2) { 369 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 370 return false; 358 371 } 359 372 psFree(where); 373 if (where2) { 374 psStringAppend(&query, " %s", where2); 375 psFree(where2); 376 } 360 377 361 378 if (faulted) { … … 366 383 psStringAppend(&query, " %s", "AND rawImfile.fault = 0"); 367 384 } 368 369 if (not_destreaked) {370 if (destreaked) {371 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense");372 return false;373 }374 if (magicked) {375 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense");376 return false;377 }378 psStringAppend(&query, " AND rawImfile.magicked = 0");379 }380 if (destreaked) {381 psStringAppend(&query, " AND rawImfile.magicked != 0");382 }383 384 385 385 386 // add the ORDER BY statement if desired … … 884 885 workdir, 885 886 label, 887 NULL, // data_group 888 NULL, // dist_group 886 889 reduction, 887 NULL, // expgroup890 NULL, // expgroup 888 891 dvodb, 889 892 tess_id, 890 end_stage 893 end_stage, 894 NULL // note 891 895 )) { 892 896 // rollback -
branches/eam_branches/20090820/ippTools/src/regtoolConfig.c
r25766 r25870 137 137 ADD_OPT(Str, processedimfileArgs, "-class_id", "search by class ID", NULL); 138 138 ADD_OPT(Str, processedimfileArgs, "-filter", "search by filter", NULL); 139 ADD_OPT(Str, processedimfileArgs, "-obs_mode", "search by obs_mod", NULL); 140 ADD_OPT(Str, processedimfileArgs, "-exp_type", "search by exposure type", NULL); 139 141 ADD_OPT(Time, processedimfileArgs, "-dateobs_begin", "search for exposures by time (>=)", NULL); 140 142 ADD_OPT(Time, processedimfileArgs, "-dateobs_end", "search for exposures by time (<)", NULL); 141 ADD_OPT(S64, processedimfileArgs, "-magicked", "search by magicked value", 0);142 ADD_OPT(Bool, processedimfileArgs, "-destreaked", "only return imfiles that have been destreaked", false);143 ADD_OPT(Bool, processedimfileArgs, "-not_destreaked", "only return imfiles that have not been destreaked", false);144 143 ADD_OPT(U64, processedimfileArgs, "-limit", "limit result set to N items", 0); 145 144 ADD_OPT(Bool, processedimfileArgs, "-faulted", "only return imfiles with a fault status set", false); 145 ADD_OPT(Bool, processedimfileArgs, "-all", "list without search arguments", false); 146 146 ADD_OPT(Bool, processedimfileArgs, "-simple", "use the simple output format", false); 147 147 ADD_OPT(Bool, processedimfileArgs, "-ordered_by_date", "force output to be in DATE order", false); 148 pxspaceAddArguments(processedimfileArgs); 149 pxmagicAddArguments(processedimfileArgs); 148 150 149 151 // -revertprocessedimfile -
branches/eam_branches/20090820/ippTools/src/stacktool.c
r25766 r25870 109 109 110 110 // required options 111 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 112 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 113 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 114 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 111 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 112 113 // optional 114 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 115 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 116 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 117 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 118 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 119 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 120 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 115 121 116 122 psMetadata *where = psMetadataAlloc(); … … 160 166 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 161 167 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 162 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 163 164 if (!psListLength(where->list) && 165 !psMetadataLookupBool(NULL, config->args, "-all")) { 168 169 if (!psListLength(where->list)) { 166 170 psFree(where); 167 171 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); … … 345 349 workdir, 346 350 label, 351 data_group ? data_group : label, 352 dist_group, 347 353 reduction, 348 354 dvodb, … … 350 356 skycell_id, 351 357 tess_id, 352 filter); 358 filter, 359 note); 353 360 354 361 if (!stackRunInsertObject(config->dbh, run)) { … … 468 475 469 476 // required options 470 PXOPT_LOOKUP_STR(workdir, config->args, "- workdir", true, false);477 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 471 478 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 472 479 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); … … 475 482 // default 476 483 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 477 PXOPT_LOOKUP_TIME(registered, config->args, "- registered", false, false);484 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 478 485 479 486 // options 480 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 481 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 482 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 487 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 488 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 489 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 490 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 491 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 492 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 483 493 484 494 // we have to support multipe exp_ids … … 495 505 workdir, 496 506 label, 507 data_group ? data_group : label, 508 dist_group, 497 509 reduction, 498 510 dvodb, … … 500 512 skycell_id, 501 513 tess_id, 502 filter); 514 filter, 515 note); 503 516 504 517 if (!run) { … … 569 582 PS_ASSERT_PTR_NON_NULL(config, false); 570 583 571 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", true, false); 584 #ifdef notdef 585 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false); 572 586 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 573 574 if (state) { 587 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 588 #endif 589 psMetadata *where = psMetadataAlloc(); 590 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); 591 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 592 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 593 if (!psListLength(where->list)) { 594 psFree(where); 595 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 596 return false; 597 } 598 599 psString query = psStringCopy("UPDATE stackRun"); 600 601 // pxUpdateRun gets parameters from config->args and updates 602 bool result = pxUpdateRun(config, where, &query, "stackRun", true); 603 604 psFree(query); 605 psFree(where); 606 607 return result; 608 609 #ifdef notdef 610 // Hack-y work around to make stacktool more like the other tools, without breaking other stuff (hopefully). 611 612 if ((state)&&(stack_id)) { 575 613 // set detRun.state to state 576 614 return setstackRunState(config, stack_id, state); 577 615 } 578 616 579 return true; 617 if ((state)&&(label)) { 618 return setstackRunStateByLabel(config, label, state); 619 } 620 621 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 622 return false; 623 #endif 580 624 } 581 625 … … 1006 1050 } 1007 1051 1052 #ifdef notdef 1053 static bool setstackRunStateByLabel(pxConfig *config, const char *label, const char *state) 1054 { 1055 PS_ASSERT_PTR_NON_NULL(state, false); 1056 1057 // check that state is a valid string value 1058 if (!pxIsValidState(state)) { 1059 psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state); 1060 return false; 1061 } 1062 1063 char *query = "UPDATE stackRun SET state = '%s' WHERE label = '%s'"; 1064 if (!p_psDBRunQueryF(config->dbh, query, state, label)) { 1065 psError(PS_ERR_UNKNOWN, false, 1066 "failed to change state for label %s", label); 1067 return false; 1068 } 1069 1070 return true; 1071 } 1072 #endif 1073 1008 1074 static bool pendingcleanuprunMode(pxConfig *config) 1009 1075 { … … 1231 1297 } 1232 1298 1299 if (!pxExportVersion(config, f)) { 1300 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1301 return false; 1302 } 1233 1303 psMetadata *where = psMetadataAlloc(); 1234 1304 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); … … 1317 1387 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1318 1388 1319 fprintf (stdout, "---- input ----\n"); 1389 #ifdef notdef 1390 fprintf (stderr, "---- input ----\n"); 1320 1391 psMetadataPrint (stderr, input, 1); 1321 1392 #endif 1393 1394 if (!pxCheckImportVersion(config, input)) { 1395 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1396 return false; 1397 } 1322 1398 psMetadataItem *item = psMetadataLookup (input, "stackRun"); 1323 1399 psAssert (item, "entry not in input?"); -
branches/eam_branches/20090820/ippTools/src/stacktoolConfig.c
r25766 r25870 47 47 // -definebyquery 48 48 psMetadata *definebyqueryArgs = psMetadataAlloc(); 49 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 50 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 51 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction", NULL); 52 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-dvodb", 0, "define dvodb", NULL); 53 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 49 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); 50 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 51 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 52 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 53 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction", NULL); 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dvodb", 0, "define dvodb", NULL); 56 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 54 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-select_skycell_id", 0, "search for skycell_id", NULL); 55 58 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-select_good_frac_min", 0, "define min good_frac", 0.0); … … 84 87 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-select_iq_m4_max", 0, "define max iq_m4", NAN); 85 88 psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-random", 0, "use this number of random elements", 0); 86 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false);87 89 psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-min_num", 0, "minimum number of inputs", 0); 88 90 psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-min_new", 0, "minimum number of new inputs", 0); … … 93 95 // -definerun 94 96 psMetadata *definerunArgs = psMetadataAlloc(); 95 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "- workdir", 0, "define workdir (required)", NULL);96 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "- label", 0, "define label", NULL);97 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "- reduction", 0, "define reduction", NULL);98 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "- dvodb", 0, "define dvodb", NULL);99 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "- registered", 0, "time detrend run was registered", now);97 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir (required)", NULL); 98 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", NULL); 99 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction", NULL); 100 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_dvodb", 0, "define dvodb", NULL); 101 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 100 102 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell ID (required)", NULL); 101 103 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-tess_id", 0, "define tessellation ID (required)", NULL); … … 106 108 // -updaterun 107 109 psMetadata *updaterunArgs = psMetadataAlloc(); 108 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stack_id", 0, "define stack ID (required)", 0); 109 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 110 110 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack ID", 0); 111 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 112 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", 0); 113 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "define new value for label", 0); 114 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "define new state", NULL); 115 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 116 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 117 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 118 111 119 // -addinputskyfile 112 120 psMetadata *addinputskyfileArgs = psMetadataAlloc(); -
branches/eam_branches/20090820/ippTools/src/warptool.c
r25766 r25870 58 58 static bool exportrunMode(pxConfig *config); 59 59 static bool importrunMode(pxConfig *config); 60 static bool runstateMode(pxConfig *config); 60 61 61 62 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile); … … 108 109 MODECASE(WARPTOOL_MODE_EXPORTRUN, exportrunMode); 109 110 MODECASE(WARPTOOL_MODE_IMPORTRUN, importrunMode); 111 MODECASE(WARPTOOL_MODE_RUNSTATE, runstateMode); 110 112 111 113 default: … … 139 141 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required 140 142 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 143 PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", false, false); 144 PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", false, false); 145 PXOPT_LOOKUP_STR(note, config->args, "-note", false, false); 141 146 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 142 147 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); // required (no default TESS) … … 160 165 "dirty", // workdir_state 161 166 label, 167 data_group ? data_group : label, 168 dist_group, 162 169 dvodb, 163 170 tess_id, … … 165 172 end_stage, 166 173 registered, 167 0 // magicked 174 0, // magicked 175 note 168 176 ); 169 177 if (!warpRun) { … … 251 259 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 252 260 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 261 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 262 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 253 263 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 254 264 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 255 265 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 256 266 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 267 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 257 268 258 269 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); … … 340 351 workdir ? workdir : row->workdir, 341 352 label ? label : row->label, 353 data_group ? data_group: row->data_group, 354 dist_group ? dist_group: row->dist_group, 342 355 dvodb ? dvodb : row->dvodb, 343 356 tess_id ? tess_id : row->tess_id, 344 357 reduction ? reduction : row->reduction, 345 end_stage ? end_stage : row->end_stage)) 358 end_stage ? end_stage : row->end_stage, 359 note)) 346 360 { 347 361 psError(PS_ERR_UNKNOWN, false, "failed to trying to queue fake_id: %" PRId64, row->fake_id); … … 371 385 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 372 386 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 373 374 if (!psListLength(where->list) 375 && !psMetadataLookupBool(NULL, config->args, "-all")) { 387 PXOPT_COPY_STR(config->args, where, "-data_group","warpRun.data_group", "=="); 388 PXOPT_COPY_STR(config->args, where, "-dist_group","warpRun.dist_group", "=="); 389 390 if (!psListLength(where->list)) { 376 391 psFree(where); 377 where = NULL;378 392 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 379 393 return false; 380 394 } 381 382 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 383 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 384 385 if ((!state) && (!label)) { 386 psError(PXTOOLS_ERR_DATA, false, "parameters (-state or -label) are required"); 387 psFree(where); 388 return false; 389 } 390 391 if (state) { 392 // set warpRun.state to state 393 if (!pxwarpRunSetStateByQuery(config, where, state)) { 394 psFree(where); 395 return false; 396 } 397 } 398 399 if (label) { 400 // set chipRun.label to label 401 if (!pxwarpRunSetLabelByQuery(config, where, label)) { 402 psFree(where); 403 return false; 404 } 405 } 406 395 396 psString query = psStringCopy("UPDATE warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 397 398 // pxUpdateRun gets parameters from config->args and updates 399 bool result = pxUpdateRun(config, where, &query, "warpRun", true); 400 401 psFree(query); 407 402 psFree(where); 408 403 409 return true; 410 } 411 404 return result; 405 } 412 406 413 407 static bool expMode(pxConfig *config) … … 1204 1198 pxAddLabelSearchArgs (config, where, "-label", "warpRun.label", "LIKE"); 1205 1199 1206 PXOPT_LOOKUP_U64(magicked, config->args, "-magicked", false, false);1207 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);1208 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false);1209 1210 1200 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1211 1201 … … 1220 1210 } 1221 1211 1212 // generate where strings for arguments that require extra processing 1213 // beyond PXOPT_COPY* 1214 psString where2 = NULL; 1215 if (!pxmagicAddWhere(config, &where2, "warpSkyfile")) { 1216 psError(PXTOOLS_ERR_DATA, false, "pxMagicAddWhere failed"); 1217 return false; 1218 } 1219 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 1220 psError(PXTOOLS_ERR_DATA, false, "pxSpaceAddWhere failed"); 1221 return false; 1222 } 1223 1222 1224 if (psListLength(where->list)) { 1223 1225 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1224 1226 psStringAppend(&query, " AND %s", whereClause); 1225 1227 psFree(whereClause); 1226 } else if (!all ) {1228 } else if (!all && !where2) { 1227 1229 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 1228 1230 return false; … … 1230 1232 psFree(where); 1231 1233 1232 if (not_destreaked) { 1233 if (destreaked) { 1234 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense"); 1235 return false; 1236 } 1237 if (magicked) { 1238 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense"); 1239 return false; 1240 } 1241 psStringAppend(&query, " AND warpSkyfile.magicked = 0"); 1242 } 1243 if (destreaked) { 1244 psStringAppend(&query, " AND warpSkyfile.magicked != 0"); 1234 if (where2) { 1235 psStringAppend(&query, " %s", where2); 1245 1236 } 1246 1237 … … 1712 1703 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 1713 1704 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1714 1715 psString query = pxDataGet("warptool_updateskyfile.sql"); 1716 1717 if (!p_psDBRunQueryF(config->dbh, query, fault, warp_id, skycell_id)) { 1718 psError(PS_ERR_UNKNOWN, false, "database error"); 1719 return false; 1720 } 1721 psFree(query); 1705 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1706 1707 if (!state) { 1708 psString query = pxDataGet("warptool_updateskyfile.sql"); 1709 1710 if (!p_psDBRunQueryF(config->dbh, query, fault, warp_id, skycell_id)) { 1711 psError(PS_ERR_UNKNOWN, false, "database error"); 1712 return false; 1713 } 1714 psFree(query); 1715 } 1716 else { 1717 if (strcmp(state,"error_cleaned") == 0) { 1718 change_skyfile_data_state(config,"error_cleaned","goto_cleaned"); 1719 } 1720 else if (strcmp(state, "error_scrubbed") == 0) { 1721 change_skyfile_data_state(config,"error_scrubbed","goto_scrubbed"); 1722 } 1723 else if (strcmp(state, "error_purged") == 0) { 1724 change_skyfile_data_state(config,"error_purged","goto_purged"); 1725 } 1726 else { 1727 psError(PS_ERR_UNKNOWN, false, "unhandled state given"); 1728 return(false); 1729 } 1730 } 1722 1731 1723 1732 return true; … … 1744 1753 } 1745 1754 1755 if (!pxExportVersion(config, f)) { 1756 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1757 return false; 1758 } 1746 1759 psMetadata *where = psMetadataAlloc(); 1747 1760 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); … … 1836 1849 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1837 1850 1838 fprintf (stdout, "---- input ----\n"); 1851 #ifdef notdef 1852 fprintf (stderr, "---- input ----\n"); 1839 1853 psMetadataPrint (stderr, input, 1); 1854 #endif 1855 1856 if (!pxCheckImportVersion(config, input)) { 1857 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1858 return false; 1859 } 1840 1860 1841 1861 psMetadataItem *item = psMetadataLookup (input, "warpRun"); … … 1900 1920 return true; 1901 1921 } 1922 1923 static bool runstateMode(pxConfig *config) 1924 { 1925 PS_ASSERT_PTR_NON_NULL(config, false); 1926 1927 psMetadata *where = psMetadataAlloc(); 1928 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "=="); 1929 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1930 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1931 pxAddLabelSearchArgs (config, where, "-label", "warpRun.label", "LIKE"); 1932 1933 // PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1934 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 1935 1936 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1937 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1938 1939 psString query = pxDataGet("warptool_runstate.sql"); 1940 if (!query) { 1941 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1942 return false; 1943 } 1944 1945 if (psListLength(where->list)) { 1946 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1947 psStringAppend(&query, " WHERE %s", whereClause); 1948 psFree(whereClause); 1949 } else { 1950 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 1951 return false; 1952 } 1953 psFree(where); 1954 1955 // treat limit == 0 as "no limit" 1956 if (limit) { 1957 psString limitString = psDBGenerateLimitSQL(limit); 1958 psStringAppend(&query, " %s", limitString); 1959 psFree(limitString); 1960 } 1961 1962 if (!p_psDBRunQuery(config->dbh, query)) { 1963 psError(PS_ERR_UNKNOWN, false, "database error"); 1964 psFree(query); 1965 return false; 1966 } 1967 psFree(query); 1968 1969 psArray *output = p_psDBFetchResult(config->dbh); 1970 if (!output) { 1971 psErrorCode err = psErrorCodeLast(); 1972 switch (err) { 1973 case PS_ERR_DB_CLIENT: 1974 psError(PXTOOLS_ERR_SYS, false, "database error"); 1975 case PS_ERR_DB_SERVER: 1976 psError(PXTOOLS_ERR_PROG, false, "database error"); 1977 default: 1978 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1979 } 1980 1981 return false; 1982 } 1983 if (!psArrayLength(output)) { 1984 psTrace("warptool", PS_LOG_INFO, "no rows found"); 1985 psFree(output); 1986 return true; 1987 } 1988 1989 if (psArrayLength(output)) { 1990 // negative simple so the default is true 1991 if (!ippdbPrintMetadatas(stdout, output, "warpRunState", !simple)) { 1992 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1993 psFree(output); 1994 return false; 1995 } 1996 } 1997 1998 psFree(output); 1999 2000 return true; 2001 } -
branches/eam_branches/20090820/ippTools/src/warptool.h
r25766 r25870 53 53 WARPTOOL_MODE_UPDATESKYFILE, 54 54 WARPTOOL_MODE_EXPORTRUN, 55 WARPTOOL_MODE_IMPORTRUN 55 WARPTOOL_MODE_IMPORTRUN, 56 WARPTOOL_MODE_RUNSTATE, 56 57 } warptoolMode; 57 58 -
branches/eam_branches/20090820/ippTools/src/warptoolConfig.c
r25766 r25870 100 100 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 101 101 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_end_stage", 0, "define end stage", NULL); 102 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 102 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 103 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 104 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 103 105 104 106 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); … … 117 119 psMetadataAddTime(definerunArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 118 120 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 121 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_end_stage", 0, "define end stage", NULL); 122 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define data group", NULL); 123 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define dist group", NULL); 124 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 119 125 120 126 // -updaterun … … 128 134 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by warpRun state", NULL); 129 135 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by warpRun label", NULL); 130 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 131 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 132 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 133 136 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-data_group", 0, "search by warpRun data_group", NULL); 137 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-dist_group", 0, "search by warpRun dist_group", NULL); 138 139 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "define new state", NULL); 140 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "define new value for label", 0); 141 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_data_group", 0, "define new data_group", NULL); 142 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_dist_group", 0, "define new dist_group", NULL); 143 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define new note", NULL); 134 144 // -exp 135 145 psMetadata *expArgs = psMetadataAlloc(); … … 218 228 psMetadataAddTime(warpedArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<=)", NULL); 219 229 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-filter", 0, "search for exposures by filter", NULL); 220 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-destreaked", 0, "search for destreaked images", false);221 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-not_destreaked", 0, "search for images that have not been destreaked", false);222 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-magicked", 0, "search by magicked value", 0);223 230 psMetadataAddS16(warpedArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 224 231 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by warpRun label", NULL); 232 // add magic related arguments 233 pxmagicAddArguments(warpedArgs); 234 // add arguments for spatial search 235 pxspaceAddArguments(warpedArgs); 225 236 226 237 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-all", 0, "search without arguments", false); … … 304 315 psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 305 316 psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-fault", 0, "new fault code", 0); 306 317 psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state", 0, "set state", 0); 318 307 319 // -exportrun 308 320 psMetadata *exportrunArgs = psMetadataAlloc(); … … 315 327 psMetadata *importrunArgs = psMetadataAlloc(); 316 328 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 329 330 // -runstate 331 psMetadata *runstateArgs = psMetadataAlloc(); 332 psMetadataAddS64(runstateArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 333 // psMetadataAddStr(runstateArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tessellation ID", NULL); 334 psMetadataAddS64(runstateArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure tag", 0); 335 psMetadataAddStr(runstateArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exposure tag", 0); 336 psMetadataAddStr(runstateArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by warpRun label", NULL); 337 psMetadataAddBool(runstateArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not necessary for result", false); 338 339 psMetadataAddU64(runstateArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 340 psMetadataAddBool(runstateArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 317 341 318 342 … … 334 358 PXOPT_ADD_MODE("-advancerun", "", WARPTOOL_MODE_ADVANCERUN, advancerunArgs); 335 359 PXOPT_ADD_MODE("-warped", "", WARPTOOL_MODE_WARPED, warpedArgs); 360 PXOPT_ADD_MODE("-runstate", "", WARPTOOL_MODE_RUNSTATE, runstateArgs); 336 361 PXOPT_ADD_MODE("-revertwarped", "", WARPTOOL_MODE_REVERTWARPED, revertwarpedArgs); 337 362 PXOPT_ADD_MODE("-block", "set a label block", WARPTOOL_MODE_BLOCK, blockArgs); -
branches/eam_branches/20090820/ippconfig/gpc1/ppImage.config
r24919 r25870 17 17 # use the deburned image instead of the raw, if it exists 18 18 USE.DEBURNED.IMAGE BOOL TRUE # use burntool-repaired image? 19 USE.BEST.BURNTOOL BOOL TRUE # require the best burntooled data 20 MASK.BURNTOOL BOOL FALSE # Mask potential burntool trails 19 21 TILTYSTREAK.APPLY BOOL FALSE # apply the 'tiltystreak' tool 20 22 NOISEMAP BOOL FALSE # Apply read noise map … … 151 153 FLAT BOOL TRUE # Flat-field normalisation 152 154 MASK BOOL TRUE # Mask bad pixels 155 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails 153 156 PATTERN BOOL TRUE # Subtract pattern noise 154 157 FRINGE BOOL FALSE # Fringe subtraction … … 177 180 FLAT BOOL TRUE # Flat-field normalisation 178 181 MASK BOOL TRUE # Mask bad pixels 182 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails 179 183 FRINGE BOOL FALSE # Fringe subtraction 180 184 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 204 208 FLAT BOOL TRUE # Flat-field normalisation 205 209 MASK BOOL TRUE # Mask bad pixels 210 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails 206 211 FRINGE BOOL FALSE # Fringe subtraction 207 212 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 329 334 FLAT BOOL TRUE # Flat-field normalisation 330 335 MASK BOOL TRUE # Mask bad pixels 336 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails 331 337 FRINGE BOOL FALSE # Fringe subtraction 332 338 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 949 955 FLAT BOOL TRUE # Flat-field normalisation 950 956 MASK BOOL TRUE # Mask bad pixels 957 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails 951 958 FRINGE BOOL FALSE # Fringe subtraction 952 959 BIN1.FITS BOOL TRUE # Save 1st binned chip image? -
branches/eam_branches/20090820/ippconfig/megacam/ppImage.config
r24893 r25870 21 21 # megacam needs fringe subtraction 22 22 FRINGE BOOL TRUE # Fringe subtraction 23 24 USE.DEBURNED.IMAGE BOOL FALSE # Skip burntool 23 25 24 26 # this table lists extra constraints which should be applied when -
branches/eam_branches/20090820/ippconfig/recipes/addstar.config
r24141 r25870 1 1 # configurable options for addstar 2 # the IMAGES.ONLY option has been deprecated: set it when defining an addstar run with addtool -image-only 3 # it is not clear we still need an addstar recipe. 2 4 3 IMAGES.ONLY BOOL TRUE5 # IMAGES.ONLY BOOL TRUE 4 6 5 FLATCORR METADATA6 # IMAGES.ONLY BOOL FALSE7 IMAGES.ONLY BOOL TRUE8 END9 10 ADDSTAR METADATA11 IMAGES.ONLY BOOL TRUE12 END7 # FLATCORR METADATA 8 # # IMAGES.ONLY BOOL FALSE 9 # IMAGES.ONLY BOOL TRUE 10 # END 11 # 12 # ADDSTAR METADATA 13 # IMAGES.ONLY BOOL TRUE 14 # END -
branches/eam_branches/20090820/ippconfig/recipes/filerules-split.mdc
r25766 r25870 228 228 PPSTAMP.OUTPUT.MASK OUTPUT {OUTPUT}.mk.fits MASK COMP_MASK FPA TRUE NONE 229 229 PPSTAMP.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits VARIANCE COMP_WT FPA TRUE NONE 230 # mosaic image used for making stamps of raw images. Not saved. 230 231 PPSTAMP.CHIP OUTPUT {OUTPUT}.ch.fits IMAGE NONE CHIP FALSE MEF 232 PPSTAMP.OUTPUT.JPEG1 OUTPUT {OUTPUT}.jpg JPEG NONE FPA TRUE NONE 231 233 232 234 PPSIM.OUTPUT OUTPUT {OUTPUT}.{CHIP.NAME}.fits IMAGE NONE CHIP TRUE SPLIT -
branches/eam_branches/20090820/ippconfig/recipes/ppImage.config
r25766 r25870 26 26 CHECK.CTE BOOL FALSE # measure CTE errors? 27 27 USE.DEBURNED.IMAGE BOOL FALSE # use burntool-repaired image? 28 USE.BEST.BURNTOOL BOOL TRUE# require the best burntooled data28 USE.BEST.BURNTOOL BOOL FALSE # require the best burntooled data 29 29 TILTYSTREAK.APPLY BOOL FALSE # apply the 'tiltystreak' tool 30 30 … … 58 58 59 59 # Which regions identified by burntool to mask. 0x01 : only unfit trails, 0x02 "up" trails, 0x04 "down" trails 60 BURNTOOL.TRAILS U16 0x0 160 BURNTOOL.TRAILS U16 0x07 61 61 62 62 # Non-linearity correction … … 150 150 FLAT BOOL TRUE # Flat-field normalisation 151 151 MASK BOOL TRUE # Mask bad pixels 152 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails153 152 FRINGE BOOL TRUE # Fringe subtraction 154 153 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 174 173 FLAT BOOL TRUE # Flat-field normalisation 175 174 MASK BOOL TRUE # Mask bad pixels 176 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails177 175 FRINGE BOOL TRUE # Fringe subtraction 178 176 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 198 196 FLAT BOOL TRUE # Flat-field normalisation 199 197 MASK BOOL TRUE # Mask bad pixels 200 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails201 198 FRINGE BOOL TRUE # Fringe subtraction 202 199 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 565 562 FLAT BOOL TRUE # Flat-field normalisation 566 563 MASK BOOL TRUE # Mask bad pixels 567 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails568 564 FRINGE BOOL TRUE # Fringe subtraction 569 565 BIN1.FITS BOOL TRUE # Save 1st binned chip image? … … 1726 1722 FLAT BOOL TRUE # Flat-field normalisation 1727 1723 MASK BOOL TRUE # Mask bad pixels 1728 MASK.BURNTOOL BOOL TRUE # Mask potential burntool trails1729 1724 PATTERN BOOL TRUE # Subtract pattern noise? 1730 1725 FRINGE BOOL TRUE # Fringe subtraction -
branches/eam_branches/20090820/ippconfig/recipes/psphot.config
r25766 r25870 300 300 BACKGROUND.YBIN S32 2400 301 301 IMSTATS_NPIX S32 50000 302 END 302 BREAK_POINT STR ENSEMBLE 303 PEAKS_NMAX S32 1000 # on first pass, only keep NMAX peaks (0 == all) 304 END -
branches/eam_branches/20090820/ippconfig/sdssmosaic/addstar.config
r21045 r25870 1 IMAGES.ONLY BOOL FALSE2 3 ADDSTAR METADATA4 IMAGES.ONLY BOOL FALSE5 END1 # IMAGES.ONLY BOOL FALSE 2 # 3 # ADDSTAR METADATA 4 # IMAGES.ONLY BOOL FALSE 5 # END -
branches/eam_branches/20090820/ippconfig/simtest/ppStack.config
r23976 r25870 1 1 PSF.MODEL STR PS_MODEL_GAUSS # Model for PSF generation 2 2 DECONV.LIMIT F32 1.5 # Deconvolution fraction for rejecting entire image 3 IMAGE.REJ F32 0.3 # Rejected pixel fraction threshold for rejecting entire image -
branches/eam_branches/20090820/ppImage/src/ppImageLoop.c
r25164 r25870 51 51 } 52 52 53 // crosstalk measurement needs to be done on the entire chip at once, and before54 // signal levels are modified by the detrending. If crosstalk measurement is55 // requested, the read-level for the images is set to CHIP.56 if (!ppImageMeasureCrosstalk(config, options, view)) {57 ESCAPE("Unable to perform crosstalk correction");58 }59 60 // crosstalk correction needs to be done on the entire chip at once, and before61 // signal levels are modified by the detrending. If crosstalk correction is62 // requested, the read-level for the images is set to CHIP.63 if (!ppImageCorrectCrosstalk(config, options, view)) {64 ESCAPE("Unable to perform crosstalk correction");65 }53 // crosstalk measurement needs to be done on the entire chip at once, and before 54 // signal levels are modified by the detrending. If crosstalk measurement is 55 // requested, the read-level for the images is set to CHIP. 56 if (!ppImageMeasureCrosstalk(config, options, view)) { 57 ESCAPE("Unable to perform crosstalk correction"); 58 } 59 60 // crosstalk correction needs to be done on the entire chip at once, and before 61 // signal levels are modified by the detrending. If crosstalk correction is 62 // requested, the read-level for the images is set to CHIP. 63 if (!ppImageCorrectCrosstalk(config, options, view)) { 64 ESCAPE("Unable to perform crosstalk correction"); 65 } 66 66 67 67 psTimerStart(TIMER_DETREND); … … 259 259 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 260 260 if (dump_file) { 261 pmConfigDump(config, dump_file); 261 if (!pmConfigDump(config, dump_file)) { 262 ESCAPE("Unable to dump configuration."); 263 } 262 264 } 263 265 -
branches/eam_branches/20090820/ppImage/src/ppImageSetMaskBits.c
r25766 r25870 38 38 psAssert (options->lowMask, "low mask not set"); 39 39 40 // mask for suspect regions due to burntool 41 options->burntoolMask = pmConfigMaskGet("BURNTOOL",config); 42 psAssert (options->burntoolMask, "burntool mask not set"); 40 // mask for suspect regions due to burntool if we need to. 41 if (options->doMaskBurntool) { 42 options->burntoolMask = pmConfigMaskGet("BURNTOOL",config); 43 psAssert (options->burntoolMask, "burntool mask not set"); 44 } 43 45 44 46 // save MASK and MARK on the PSPHOT recipe -
branches/eam_branches/20090820/ppMerge/src/ppMergeLoop.c
r24908 r25870 104 104 goto ERROR; 105 105 } 106 // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell107 zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32);106 // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell 107 zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32); 108 108 // Flow through 109 109 case PPMERGE_TYPE_FLAT: … … 150 150 goto ERROR; 151 151 } 152 153 154 // Average concepts across inputs 155 { 156 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs 157 for (int i = 0; i < numFiles; i++) { 158 pmFPAfile *input = inputs->data[i]; ///< Input file 159 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa); 160 } 161 if (!pmConceptsAverageFPAs(output->fpa, inFPAs)) { 162 psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts."); 163 psFree(inFPAs); 164 goto ERROR; 165 } 166 psFree(inFPAs); 167 } 168 152 169 pmChip *outChip; ///< Chip of interest 153 170 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { … … 158 175 goto ERROR; 159 176 } 177 178 // Average concepts across inputs 179 { 180 psList *inChips = psListAlloc(NULL); 181 for (int i=0; i < numFiles; i++) { 182 pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa); 183 psListAdd(inChips, PS_LIST_TAIL, chip); 184 } 185 if (!pmConceptsAverageChips(outChip, inChips, true)) { 186 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 187 psFree(inChips); 188 goto ERROR; 189 } 190 psFree(inChips); 191 } 192 160 193 pmCell *outCell; ///< Cell of interest 161 194 162 // XXX TEST : force a single loop195 // XXX TEST : force a single loop 163 196 // outCell = pmFPAviewNextCell(view, outFPA, 1); { 164 197 165 198 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 166 if (!outCell->process || !outCell->file_exists) {167 continue;168 }199 if (!outCell->process || !outCell->file_exists) { 200 continue; 201 } 169 202 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 170 203 goto ERROR; … … 206 239 } 207 240 208 if (zeroSet) {209 for (int i = 0; i < zeroSet->numRows; i++) {210 zeros->data.F32[i] = zeroSet->data.F32[i][cellNum];211 }212 }213 214 int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk215 if (!rows && nThreads) {216 psError(PS_ERR_UNKNOWN, false, "Invalid combination of threads > 0 and ROWS == 0 (ie, multiple threads working on the full array...)");217 goto ERROR;218 }241 if (zeroSet) { 242 for (int i = 0; i < zeroSet->numRows; i++) { 243 zeros->data.F32[i] = zeroSet->data.F32[i][cellNum]; 244 } 245 } 246 247 int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk 248 if (!rows && nThreads) { 249 psError(PS_ERR_UNKNOWN, false, "Invalid combination of threads > 0 and ROWS == 0 (ie, multiple threads working on the full array...)"); 250 goto ERROR; 251 } 219 252 220 253 ppMergeFileGroup *fileGroup = NULL; … … 227 260 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j); 228 261 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell 229 pmReadout *readout = pmReadoutAlloc(inCell);230 readout->process = true; // until proven otherwise, attempt to process this readout262 pmReadout *readout = pmReadoutAlloc(inCell); 263 readout->process = true; // until proven otherwise, attempt to process this readout 231 264 readouts->data[j] = readout; 232 265 } … … 361 394 362 395 psFree(fileGroups); 363 psFree(zeros);396 psFree(zeros); 364 397 365 398 // XXX eventually need to keep both the shutter and the pattern, as we do with dark … … 424 457 // Put the new readout into the cell after the existing readouts. 425 458 if (type == PPMERGE_TYPE_FRINGE && outRO) { 426 if (fringeSmooth) {427 if (outRO->mask) {428 psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2);429 psFree (outRO->image);430 outRO->image = smoothed;431 } else {432 psImageSmooth (outRO->image, fringeSmoothSigma, 3);433 }434 }459 if (fringeSmooth) { 460 if (outRO->mask) { 461 psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2); 462 psFree (outRO->image); 463 outRO->image = smoothed; 464 } else { 465 psImageSmooth (outRO->image, fringeSmoothSigma, 3); 466 } 467 } 435 468 436 469 pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY); … … 447 480 448 481 // XXX replaced this : pmFringesFormat(outCell, NULL, fringes); 449 if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) {450 psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n");451 goto ERROR;452 }482 if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) { 483 psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n"); 484 goto ERROR; 485 } 453 486 psFree(fringes); // Drop reference 454 487 } … … 472 505 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 473 506 474 if (0) {475 psFits *fits = NULL;476 fits = psFitsOpen ("combine.fits", "w");477 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL);478 psFitsClose (fits);479 480 fits = psFitsOpen ("inmask.fits", "w");481 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL);482 psFitsClose (fits);483 }507 if (0) { 508 psFits *fits = NULL; 509 fits = psFitsOpen ("combine.fits", "w"); 510 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL); 511 psFitsClose (fits); 512 513 fits = psFitsOpen ("inmask.fits", "w"); 514 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 515 psFitsClose (fits); 516 } 484 517 485 518 psF32 **outputImage = outRO->image->data.F32; … … 493 526 } 494 527 495 if (0) {496 psFits *fits = NULL;497 fits = psFitsOpen ("otmask.fits", "w");498 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL);499 psFitsClose (fits);500 }528 if (0) { 529 psFits *fits = NULL; 530 fits = psFitsOpen ("otmask.fits", "w"); 531 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 532 psFitsClose (fits); 533 } 501 534 502 535 } … … 510 543 } 511 544 512 if (outChip->data_exists) {513 psList *inChips = psListAlloc(NULL);514 for (int i=0; i < numFiles; i++) {515 pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa);516 psListAdd(inChips, PS_LIST_TAIL, chip);517 }518 if (!pmConceptsAverageChips(outChip, inChips, true)) {519 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");520 psFree(inChips);521 goto ERROR;522 }523 psFree(inChips);524 }525 545 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 526 546 goto ERROR; 527 547 } 528 548 } 529 530 // Get list of FPAs for concepts averaging531 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs532 for (int i = 0; i < numFiles; i++) {533 pmFPAfile *input = inputs->data[i]; ///< Input file534 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa);535 }536 if (!pmConceptsAverageFPAs(output->fpa, inFPAs)) {537 psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts.");538 psFree(inFPAs);539 goto ERROR;540 }541 psFree(inFPAs);542 543 549 544 550 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { -
branches/eam_branches/20090820/ppStack/src/ppStackFinish.c
r23753 r25870 66 66 psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config 67 67 if (dump) { 68 pmConfigDump(config, dump); 68 if (!pmConfigDump(config, dump)) { 69 psError(PS_ERR_IO, false, "Unable to dump configuration."); 70 return false; 71 } 69 72 } 70 73 -
branches/eam_branches/20090820/ppSub/src/ppSub.c
r23753 r25870 76 76 psTimerStop(); 77 77 78 psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig"); 79 if (dump_file) { 80 if (!pmConfigDump(data->config, dump_file)) { 81 psErrorStackPrint(stderr, "Unable to dump configuration.\n"); 82 exitValue = PS_EXIT_SYS_ERROR; 83 } 84 } 78 85 psFree(data); 79 86 -
branches/eam_branches/20090820/ppSub/src/ppSubData.c
r23753 r25870 29 29 psFree(data->stats); 30 30 31 psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig");32 if (dump_file) {33 pmConfigDump(data->config, dump_file);34 }35 31 psFree(data->config); 36 32 -
branches/eam_branches/20090820/psModules/src/camera/pmFPAfileFitsIO.c
r25168 r25870 179 179 pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest, or NULL 180 180 pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest, or NULL 181 if (!pmFPAUpdateNames(fpa, chip, cell, file->imageId, file->sourceId)) {182 psError(PS_ERR_UNKNOWN, false, "Unable to update names in header.");183 return false;184 }185 186 181 if (cell) { 187 182 if (!pmConceptsWriteCell(cell, true, config)) { … … 196 191 } else if (!pmConceptsWriteFPA(fpa, true, config)) { 197 192 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 193 return false; 194 } 195 196 if (!pmFPAUpdateNames(fpa, chip, cell, file->imageId, file->sourceId)) { 197 psError(PS_ERR_UNKNOWN, false, "Unable to update names in header."); 198 198 return false; 199 199 } -
branches/eam_branches/20090820/psModules/src/camera/pmReadoutFake.c
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/psModules/src/config/pmConfigMask.c
r25766 r25870 16 16 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 17 17 { "CTE", "DETECTOR", 0x01, true }, // Pixel has poor CTE 18 { "BURNTOOL", NULL, 0x04, false }, // Pixel has been touched by burntool 18 19 // Invalid signal ranges 19 20 { "SAT", NULL, 0x02, true }, // Pixel is saturated or non-linear -
branches/eam_branches/20090820/psModules/src/objects/pmPSF_IO.c
r21183 r25870 321 321 pmPSFClump psfClump; 322 322 323 // we now save clump parameters for each region : need to save all of those324 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");325 psMetadataAddS32 (header, PS_LIST_TAIL, "PSF_CLN", PS_META_REPLACE, "number of psf clump regions", nRegions);326 for (int i = 0; i < nRegions; i++) {327 char regionName[64];328 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i);329 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);330 331 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); assert (status);332 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); assert (status);333 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); assert (status);334 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); assert (status);335 336 char key[16];337 snprintf (key, 9, "CLX_%03d", i);338 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump center", psfClump.X);339 snprintf (key, 9, "CLY_%03d", i);340 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump center", psfClump.Y);341 snprintf (key, 9, "CLDX_%03d", i);342 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump size", psfClump.dX);343 snprintf (key, 9, "CLDY_%03d", i);344 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump size", psfClump.dY);345 }323 // we now save clump parameters for each region : need to save all of those 324 int nRegions = psMetadataLookupS32 (&status, analysis, "PSF.CLUMP.NREGIONS"); 325 psMetadataAddS32 (header, PS_LIST_TAIL, "PSF_CLN", PS_META_REPLACE, "number of psf clump regions", nRegions); 326 for (int i = 0; i < nRegions; i++) { 327 char regionName[64]; 328 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i); 329 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 330 331 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); assert (status); 332 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); assert (status); 333 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); assert (status); 334 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); assert (status); 335 336 char key[16]; 337 snprintf (key, 9, "CLX_%03d", i); 338 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump center", psfClump.X); 339 snprintf (key, 9, "CLY_%03d", i); 340 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump center", psfClump.Y); 341 snprintf (key, 9, "CLDX_%03d", i); 342 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump size", psfClump.dX); 343 snprintf (key, 9, "CLDY_%03d", i); 344 psMetadataAddF32 (header, PS_LIST_TAIL, key, PS_META_REPLACE, "psf clump size", psfClump.dY); 345 } 346 346 347 347 // save the dimensions of each parameter … … 667 667 int nRegions = psMetadataLookupS32 (&status, header, "PSF_CLN"); 668 668 if (!status) { 669 // read old-style psf clump data670 671 char regionName[64];672 snprintf (regionName, 64, "PSF.CLUMP.REGION.000");673 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1);674 675 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);676 if (!regionMD) {677 regionMD = psMetadataAlloc();678 psMetadataAddMetadata (recipe, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD);679 psFree (regionMD);680 }681 682 // psf clump data683 pmPSFClump psfClump;684 685 psfClump.X = psMetadataLookupF32 (&status, header, "PSF_CLX" ); assert(status);686 psfClump.Y = psMetadataLookupF32 (&status, header, "PSF_CLY" ); assert(status);687 psfClump.dX = psMetadataLookupF32 (&status, header, "PSF_CLDX"); assert(status);688 psfClump.dY = psMetadataLookupF32 (&status, header, "PSF_CLDY"); assert(status);689 690 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X);691 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y);692 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);693 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);669 // read old-style psf clump data 670 671 char regionName[64]; 672 snprintf (regionName, 64, "PSF.CLUMP.REGION.000"); 673 psMetadataAddS32 (analysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1); 674 675 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 676 if (!regionMD) { 677 regionMD = psMetadataAlloc(); 678 psMetadataAddMetadata (analysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 679 psFree (regionMD); 680 } 681 682 // psf clump data 683 pmPSFClump psfClump; 684 685 psfClump.X = psMetadataLookupF32 (&status, header, "PSF_CLX" ); assert(status); 686 psfClump.Y = psMetadataLookupF32 (&status, header, "PSF_CLY" ); assert(status); 687 psfClump.dX = psMetadataLookupF32 (&status, header, "PSF_CLDX"); assert(status); 688 psfClump.dY = psMetadataLookupF32 (&status, header, "PSF_CLDY"); assert(status); 689 690 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 691 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 692 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 693 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 694 694 } else { 695 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegions);696 697 for (int i = 0; i < nRegions; i++) {698 char key[10];699 char regionName[64];700 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i);701 702 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);703 if (!regionMD) {704 regionMD = psMetadataAlloc();705 psMetadataAddMetadata (recipe, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD);706 psFree (regionMD);707 }708 709 // psf clump data710 pmPSFClump psfClump;711 712 snprintf (key, 9, "CLX_%03d", i);713 psfClump.X = psMetadataLookupF32 (&status, header, key); assert(status);714 snprintf (key, 9, "CLY_%03d", i);715 psfClump.Y = psMetadataLookupF32 (&status, header, key); assert(status);716 snprintf (key, 9, "CLDX_%03d", i);717 psfClump.dX = psMetadataLookupF32 (&status, header, key); assert(status);718 snprintf (key, 9, "CLDY_%03d", i);719 psfClump.dY = psMetadataLookupF32 (&status, header, key); assert(status);720 721 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X);722 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y);723 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);724 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);725 }695 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegions); 696 697 for (int i = 0; i < nRegions; i++) { 698 char key[10]; 699 char regionName[64]; 700 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i); 701 702 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 703 if (!regionMD) { 704 regionMD = psMetadataAlloc(); 705 psMetadataAddMetadata (analysis, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 706 psFree (regionMD); 707 } 708 709 // psf clump data 710 pmPSFClump psfClump; 711 712 snprintf (key, 9, "CLX_%03d", i); 713 psfClump.X = psMetadataLookupF32 (&status, header, key); assert(status); 714 snprintf (key, 9, "CLY_%03d", i); 715 psfClump.Y = psMetadataLookupF32 (&status, header, key); assert(status); 716 snprintf (key, 9, "CLDX_%03d", i); 717 psfClump.dX = psMetadataLookupF32 (&status, header, key); assert(status); 718 snprintf (key, 9, "CLDY_%03d", i); 719 psfClump.dY = psMetadataLookupF32 (&status, header, key); assert(status); 720 721 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 722 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 723 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 724 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 725 } 726 726 } 727 727 … … 871 871 psFitsReadImageBuffer(psf->residuals->Ry, file->fits, fullImage, 2); // Desired pixels 872 872 } 873 // XXX notice that we are not saving the resid->mask873 // XXX notice that we are not saving the resid->mask 874 874 } 875 875 -
branches/eam_branches/20090820/psModules/src/objects/pmPSFtryModel.c
r25766 r25870 70 70 psFree(psfTry); 71 71 return NULL; 72 } 73 74 int orderMin = (options->psfTrendMode == PM_TREND_MAP) ? 1 : 0;72 } 73 74 // XXX set the min number of needed source more carefully (depends on psfTrendMode?) 75 75 int orderMax = PS_MAX (options->psfTrendNx, options->psfTrendNy); 76 77 // XXX set the min number of needed source more carefully (depends on psfTrendMode?)78 76 if ((sources->n < 15) && (orderMax >= 3)) orderMax = 2; 79 77 if ((sources->n < 11) && (orderMax >= 2)) orderMax = 1; 80 78 if ((sources->n < 8) && (orderMax >= 1)) orderMax = 0; 81 79 if ((sources->n < 3)) { 82 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 83 return NULL; 80 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 81 return NULL; 82 } 83 84 int orderMin; 85 if (options->psfTrendMode == PM_TREND_MAP) { 86 orderMin = 1; 87 orderMax = PS_MAX(orderMax, 1); 88 } else { 89 orderMin = 0; 84 90 } 85 91 … … 87 93 psVector *srcMask = psVectorCopy (NULL, psfTry->mask, PS_TYPE_VECTOR_MASK); 88 94 89 // we will save the PSF with the best fit (min systematic error) 95 // we will save the PSF with the best fit (min systematic error) 90 96 pmPSF *minPSF = NULL; 91 97 psVector *minMask = NULL; … … 96 102 int Ny = options->psfTrendNy; 97 103 for (int i = orderMin; i <= orderMax; i++) { 98 99 if (Nx > Ny) {100 options->psfTrendNx = i;101 options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5));102 } else {103 options->psfTrendNy = i;104 options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5));105 }106 107 // free existing data, if any108 psFree(psfTry->psf);109 psFree(psfTry->mask);110 111 // allocate a mask and a psf model using the current Nx,Ny order values;112 psfTry->psf = pmPSFAlloc (options);113 psfTry->mask = psVectorCopy (NULL, srcMask, PS_TYPE_VECTOR_MASK);114 115 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation116 if (!pmPSFtryMakePSF (psfTry)) {117 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources");118 psFree(psfTry);119 return NULL;120 }121 122 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric123 if (!pmPSFtryFitPSF (psfTry, options, maskVal, markVal)) {124 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources");125 psFree(psfTry);126 return NULL;127 }128 129 // stage 4: measure systematic error in pmPSFtry->metric130 if (!pmPSFtryMetric (psfTry)) {131 psError(PS_ERR_UNKNOWN, false, "failed to measure systematic error of metric");132 psFree(psfTry);133 return NULL;134 }135 136 if (!minPSF) {137 minPSF = psMemIncrRefCounter(psfTry->psf);138 minMask = psMemIncrRefCounter(psfTry->mask);139 }140 141 if (psfTry->psf->dApResid < minPSF->dApResid) {142 psFree (minPSF);143 psFree (minMask);144 minPSF = psMemIncrRefCounter(psfTry->psf);145 minMask = psMemIncrRefCounter(psfTry->mask);146 }104 105 if (Nx > Ny) { 106 options->psfTrendNx = i; 107 options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5)); 108 } else { 109 options->psfTrendNy = i; 110 options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5)); 111 } 112 113 // free existing data, if any 114 psFree(psfTry->psf); 115 psFree(psfTry->mask); 116 117 // allocate a mask and a psf model using the current Nx,Ny order values; 118 psfTry->psf = pmPSFAlloc (options); 119 psfTry->mask = psVectorCopy (NULL, srcMask, PS_TYPE_VECTOR_MASK); 120 121 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation 122 if (!pmPSFtryMakePSF (psfTry)) { 123 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 124 psFree(psfTry); 125 return NULL; 126 } 127 128 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric 129 if (!pmPSFtryFitPSF (psfTry, options, maskVal, markVal)) { 130 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 131 psFree(psfTry); 132 return NULL; 133 } 134 135 // stage 4: measure systematic error in pmPSFtry->metric 136 if (!pmPSFtryMetric (psfTry)) { 137 psError(PS_ERR_UNKNOWN, false, "failed to measure systematic error of metric"); 138 psFree(psfTry); 139 return NULL; 140 } 141 142 if (!minPSF) { 143 minPSF = psMemIncrRefCounter(psfTry->psf); 144 minMask = psMemIncrRefCounter(psfTry->mask); 145 } 146 147 if (psfTry->psf->dApResid < minPSF->dApResid) { 148 psFree (minPSF); 149 psFree (minMask); 150 minPSF = psMemIncrRefCounter(psfTry->psf); 151 minMask = psMemIncrRefCounter(psfTry->mask); 152 } 147 153 } 148 154 psFree (srcMask); … … 153 159 psfTry->psf = minPSF; 154 160 psfTry->mask = minMask; 155 161 156 162 // XXXXX this is probably not used any more. Are the chisq of the fits so bad? can we 157 163 // fix them by softening the errors on the brightest pixels? -
branches/eam_branches/20090820/psconfig/pscheckperl
r24670 r25870 9 9 for (; @ARGV > 0; ) { 10 10 if ($ARGV[0] eq "-version") { 11 $version = $ARGV[1];11 $version = $ARGV[1]; 12 12 shift; shift; next; 13 13 } 14 14 if ($ARGV[0] eq "-build") { 15 $build = 1;15 $build = 1; 16 16 shift; next; 17 17 } 18 18 if ($ARGV[0] eq "-force") { 19 $force{$ARGV[1]} = 1;20 shift; shift; next;19 $force{$ARGV[1]} = 1; 20 shift; shift; next; 21 21 } 22 22 if ($ARGV[0] eq "-h") { &usage (); } … … 31 31 if ( @ARGV > 1) { &usage(); } 32 32 33 if ( @ARGV == 0) { 33 if ( @ARGV == 0) { 34 34 @list = <$tagsets/*.perl>; 35 35 $file = $list[-1]; … … 79 79 ($N, $module, $tarball, $modver, $prompts) = split (" ", $line); 80 80 81 if ($modver eq "") { $modver = 0; } 81 if ($modver eq "") { $modver = 0; } 82 82 system ("pscheckmods $module $modver"); 83 if (($? == 0) and not defined $force{$module} and not defined $force{'all'}) { 84 # print "$module: found\n";85 next; 83 if (($? == 0) and not defined $force{$module} and not defined $force{'all'}) { 84 # print "$module: found\n"; 85 next; 86 86 } 87 87 88 88 if (defined $force{$module}) { 89 print "$module: force\n";89 print "$module: force\n"; 90 90 } else { 91 print "$module: missing\n";91 print "$module: missing\n"; 92 92 } 93 unless ($build or defined $force{$module} or defined $force{'all'}) { 94 $Nmissing ++;95 push @missing, $module;96 next; 93 unless ($build or defined $force{$module} or defined $force{'all'}) { 94 $Nmissing ++; 95 push @missing, $module; 96 next; 97 97 } 98 98 … … 102 102 print "extract $module from $tarball\n"; 103 103 vsystem ("tar xvzf $tarball"); 104 104 105 105 ($tardir) = $tarball =~ m|(\S*).tar.gz|; 106 106 print "tardir: $tardir\n"; … … 108 108 chdir $tardir; 109 109 110 # build the MakeMaker makefile, setting the output directories 111 if ($prompts) { 112 @answers = split (",", $prompts); 113 open (PIPE, "|perl Makefile.PL PREFIX=$prefix LIB=$perldir"); 114 foreach $answer (@answers) { 115 print PIPE "$answer\n"; 116 } 117 close (PIPE); 110 if (-e "Build.PL") { 111 vsystem("psbuildperl"); 112 vsystem("Build"); 113 vsystem("Build install"); 118 114 } else { 119 vsystem ("perl Makefile.PL PREFIX=$prefix LIB=$perldir"); 115 # build the MakeMaker makefile, setting the output directories 116 if ($prompts) { 117 @answers = split (",", $prompts); 118 open (PIPE, "|perl Makefile.PL PREFIX=$prefix LIB=$perldir"); 119 foreach $answer (@answers) { 120 print PIPE "$answer\n"; 121 } 122 close (PIPE); 123 } else { 124 vsystem ("perl Makefile.PL PREFIX=$prefix LIB=$perldir"); 125 } 126 127 vsystem ("make < /dev/null"); 128 vsystem ("make install"); 120 129 } 121 122 vsystem ("make < /dev/null");123 vsystem ("make install");124 130 125 131 chdir $homedir; … … 127 133 if (!$build) { 128 134 if ($Nmissing > 0) { 129 print "The following $Nmissing perl modules are missing from your system\n";130 foreach $name (@missing) {131 print " $name\n";132 }133 print "you may install them in your local path by re-running pscheckperl with -build\n";135 print "The following $Nmissing perl modules are missing from your system\n"; 136 foreach $name (@missing) { 137 print " $name\n"; 138 } 139 print "you may install them in your local path by re-running pscheckperl with -build\n"; 134 140 } else { 135 print "no perl modules are missing from your system\n";141 print "no perl modules are missing from your system\n"; 136 142 } 137 143 } … … 152 158 @list = <$tagsets/*.perl>; 153 159 foreach $line (@list) { 154 chomp $line;155 ($dist) = $line =~ m|$tagsets/(\S*).perl|;156 print STDERR "$dist\n";160 chomp $line; 161 ($dist) = $line =~ m|$tagsets/(\S*).perl|; 162 print STDERR "$dist\n"; 157 163 } 158 164 exit 2; -
branches/eam_branches/20090820/psconfig/tagsets/ipp-2.9.perl
r25766 r25870 2 2 00 Getopt::Long Getopt-Long-2.36.tar.gz 2.3 n 3 3 00 Module::Build Module-Build-0.2806.tar.gz 0.2806 4 01 ExtUtils::MakeMaker ExtUtils-MakeMaker-6. 31.tar.gz 04 01 ExtUtils::MakeMaker ExtUtils-MakeMaker-6.54.tar.gz 0 5 5 02 Params::Validate Params-Validate-0.92.tar.gz 0.92 6 6 # 02 Apache::Test Apache-Test-1.29.tar.gz 1.29 -
branches/eam_branches/20090820/psphot/doc/efficiency.txt
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/psphot/src/psphot.h
r25766 r25870 182 182 bool psphotVisualShowFootprints (pmDetections *detections); 183 183 bool psphotVisualShowMoments (psArray *sources); 184 bool psphotVisualPlotMoments (psMetadata *recipe, ps Array *sources);184 bool psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources); 185 185 bool psphotVisualShowRoughClass (psArray *sources); 186 186 bool psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources); … … 193 193 bool psphotVisualShowResidualImage (pmReadout *readout); 194 194 bool psphotVisualPlotApResid (psArray *sources, float mean, float error); 195 bool psphotVisualPlotSourceSize (psMetadata *recipe, ps Array *sources);195 bool psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources); 196 196 bool psphotVisualShowPetrosians (psArray *sources); 197 197 … … 212 212 // bool psphotPetrosianVisualProfileRadii (psVector *radius, psVector *flux, psVector *radiusBin, psVector *fluxBin, float peakFlux, float RadiusRef); 213 213 // bool psphotPetrosianVisualEllipticalContour (pmPetrosian *petrosian); 214 // bool psphotPetrosianVisualStats (psVector *radBin, psVector *fluxBin, 215 // psVector *refRadius, psVector *meanSB,216 // psVector *petRatio, psVector *petRatioErr, psVector *fluxSum,217 // float petRadius, float ratioForRadius,218 // float petFlux, float radiusForFlux);214 // bool psphotPetrosianVisualStats (psVector *radBin, psVector *fluxBin, 215 // psVector *refRadius, psVector *meanSB, 216 // psVector *petRatio, psVector *petRatioErr, psVector *fluxSum, 217 // float petRadius, float ratioForRadius, 218 // float petFlux, float radiusForFlux); 219 219 220 220 bool psphotImageQuality (psMetadata *recipe, psArray *sources); -
branches/eam_branches/20090820/psphot/src/psphotFake.c
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090820/psphot/src/psphotRoughClass.c
r25766 r25870 1 1 # include "psphotInternal.h" 2 2 3 # define CHECK_STATUS(S,MSG) { \4 if (!status) {\5 psError(PSPHOT_ERR_CONFIG, false, "missing PSF Clump entry: %s\n", MSG); \6 return false;\7 } }3 # define CHECK_STATUS(S,MSG) { \ 4 if (!status) { \ 5 psError(PSPHOT_ERR_CONFIG, false, "missing PSF Clump entry: %s\n", MSG); \ 6 return false; \ 7 } } 8 8 9 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata * recipe, const bool havePSF);9 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *target, psMetadata *recipe, const bool havePSF); 10 10 11 11 // 2006.02.02 : no leaks … … 24 24 int nRegion = 0; 25 25 for (int ix = 0; ix < NX; ix ++) { 26 for (int iy = 0; iy < NY; iy ++) {26 for (int iy = 0; iy < NY; iy ++) { 27 27 28 psRegion *region = psRegionAlloc (ix*dX, (ix + 1)*dX, iy*dY, (iy + 1)*dY);29 if (!psphotRoughClassRegion (nRegion, region, sources, recipe, havePSF)) {30 psLogMsg ("psphot", 4, "Failed to determine rough classification for region %f,%f - %f,%f\n", 31 region->x0, region->y0, region->x1, region->y1);32 psFree (region);33 continue;34 }35 psFree (region);36 nRegion ++;37 }28 psRegion *region = psRegionAlloc (ix*dX, (ix + 1)*dX, iy*dY, (iy + 1)*dY); 29 if (!psphotRoughClassRegion (nRegion, region, sources, readout->analysis, recipe, havePSF)) { 30 psLogMsg ("psphot", 4, "Failed to determine rough classification for region %f,%f - %f,%f\n", 31 region->x0, region->y0, region->x1, region->y1); 32 psFree (region); 33 continue; 34 } 35 psFree (region); 36 nRegion ++; 37 } 38 38 } 39 39 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegion); … … 44 44 psLogMsg ("psphot.roughclass", PS_LOG_INFO, "rough classification: %f sec\n", psTimerMark ("psphot.rough")); 45 45 46 psphotVisualPlotMoments (recipe, sources);46 psphotVisualPlotMoments (recipe, readout->analysis, sources); 47 47 psphotVisualShowRoughClass (sources); 48 48 // XXX better visualization: psphotVisualShowFlags (sources); … … 51 51 } 52 52 53 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata * recipe, const bool havePSF) {53 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *target, psMetadata *recipe, const bool havePSF) { 54 54 55 55 bool status; … … 62 62 63 63 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", nRegion); 64 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);64 psMetadata *regionMD = psMetadataLookupPtr (&status, target, regionName); 65 65 if (!regionMD) { 66 // allocate the region metadata folder and add this region to it.67 regionMD = psMetadataAlloc();68 psMetadataAddMetadata (recipe, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD);69 psFree (regionMD);66 // allocate the region metadata folder and add this region to it. 67 regionMD = psMetadataAlloc(); 68 psMetadataAddMetadata (target, PS_LIST_TAIL, regionName, PS_META_REPLACE, "psf clump region", regionMD); 69 psFree (regionMD); 70 70 } 71 71 psMetadataAddPtr (regionMD, PS_LIST_TAIL, "REGION", PS_DATA_REGION | PS_META_REPLACE, "psf clump region", region); 72 72 73 73 if (!havePSF) { 74 // determine the PSF parameters from the source moment values75 // XXX why not save the psfClump as a PTR?76 psfClump = pmSourcePSFClump (region, sources, recipe);77 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X);78 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y);79 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);80 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);74 // determine the PSF parameters from the source moment values 75 // XXX why not save the psfClump as a PTR? 76 psfClump = pmSourcePSFClump (region, sources, target); 77 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 78 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 79 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 80 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 81 81 } else { 82 // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y83 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 84 if (!status) {85 psLogMsg ("psphot", 4, "No PSF clump defined for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);86 return false;87 } 88 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); psAssert (status, "missing PSF.CLUMP.Y");89 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); psAssert (status, "missing PSF.CLUMP.DX");90 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); psAssert (status, "missing PSF.CLUMP.DY");82 // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y 83 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 84 if (!status) { 85 psLogMsg ("psphot", 4, "No PSF clump defined for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1); 86 return false; 87 } 88 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); psAssert (status, "missing PSF.CLUMP.Y"); 89 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); psAssert (status, "missing PSF.CLUMP.DX"); 90 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); psAssert (status, "missing PSF.CLUMP.DY"); 91 91 } 92 92 93 93 if (psfClump.X < 0) { 94 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump");95 return false;94 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump"); 95 return false; 96 96 } 97 97 if (!psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) { 98 psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);99 return false;98 psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1); 99 return false; 100 100 } 101 101 psLogMsg ("psphot", 3, "psf clump X, Y: %f, %f\n", psfClump.X, psfClump.Y); … … 104 104 // group into STAR, COSMIC, EXTENDED, SATURATED, etc. 105 105 if (!pmSourceRoughClass (region, sources, recipe, psfClump, maskSat)) { 106 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass");107 return false;106 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass"); 107 return false; 108 108 } 109 109 -
branches/eam_branches/20090820/psphot/src/psphotSourceSize.c
r25766 r25870 83 83 psLogMsg ("psphot.size", PS_LOG_INFO, "measure source sizes for %ld sources: %f sec\n", sources->n - first, psTimerMark ("psphot.size")); 84 84 85 psphotVisualPlotSourceSize (recipe, sources);85 psphotVisualPlotSourceSize (recipe, readout->analysis, sources); 86 86 psphotVisualShowSourceSize (readout, sources); 87 87 psphotVisualPlotApResid (sources, options.ApResid, options.ApSysErr); … … 103 103 pmFootprint *footprint = peak->footprint; 104 104 if (!footprint) { 105 // if we have not footprint, use the old code to mask by isophot106 psphotMaskCosmicRayIsophot (source, maskVal, crMask);107 return true;105 // if we have not footprint, use the old code to mask by isophot 106 psphotMaskCosmicRayIsophot (source, maskVal, crMask); 107 return true; 108 108 } 109 109 110 110 if (!footprint->spans) { 111 // if we have no footprint, use the old code to mask by isophot112 psphotMaskCosmicRayIsophot (source, maskVal, crMask);113 return true;111 // if we have no footprint, use the old code to mask by isophot 112 psphotMaskCosmicRayIsophot (source, maskVal, crMask); 113 return true; 114 114 } 115 115 116 116 // mask all of the pixels covered by the spans of the footprint 117 117 for (int j = 1; j < footprint->spans->n; j++) { 118 pmSpan *span1 = footprint->spans->data[j];119 120 int iy = span1->y;121 int xs = span1->x0;122 int xe = span1->x1;123 124 for (int ix = xs; ix < xe; ix++) {125 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;126 }118 pmSpan *span1 = footprint->spans->data[j]; 119 120 int iy = span1->y; 121 int xs = span1->x0; 122 int xe = span1->x1; 123 124 for (int ix = xs; ix < xe; ix++) { 125 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 126 } 127 127 } 128 128 return true; … … 147 147 // mark the pixels in this row to the left, then the right 148 148 for (int ix = xo; ix >= 0; ix--) { 149 float SN = pixels->data.F32[yo][ix] / sqrt(variance->data.F32[yo][ix]);150 if (SN > SN_LIMIT) {151 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;152 }149 float SN = pixels->data.F32[yo][ix] / sqrt(variance->data.F32[yo][ix]); 150 if (SN > SN_LIMIT) { 151 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask; 152 } 153 153 } 154 154 for (int ix = xo + 1; ix < pixels->numCols; ix++) { 155 float SN = pixels->data.F32[yo][ix] / sqrt(variance->data.F32[yo][ix]);156 if (SN > SN_LIMIT) {157 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;158 }155 float SN = pixels->data.F32[yo][ix] / sqrt(variance->data.F32[yo][ix]); 156 if (SN > SN_LIMIT) { 157 mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask; 158 } 159 159 } 160 160 … … 162 162 // first go up: 163 163 for (int iy = PS_MIN(yo, mask->numRows-2); iy >= 0; iy--) { 164 // mark the pixels in this row to the left, then the right165 for (int ix = 0; ix < pixels->numCols; ix++) {166 float SN = pixels->data.F32[iy][ix] / sqrt(variance->data.F32[iy][ix]);167 if (SN < SN_LIMIT) continue;168 169 bool valid = false;170 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix] & crMask);171 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix-1] & crMask) : 0;172 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix+1] & crMask) : 0;173 174 if (!valid) continue;175 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;176 }164 // mark the pixels in this row to the left, then the right 165 for (int ix = 0; ix < pixels->numCols; ix++) { 166 float SN = pixels->data.F32[iy][ix] / sqrt(variance->data.F32[iy][ix]); 167 if (SN < SN_LIMIT) continue; 168 169 bool valid = false; 170 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix] & crMask); 171 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix-1] & crMask) : 0; 172 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix+1] & crMask) : 0; 173 174 if (!valid) continue; 175 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 176 } 177 177 } 178 178 // next go down: 179 179 for (int iy = PS_MIN(yo+1, mask->numRows-1); iy < pixels->numRows; iy++) { 180 // mark the pixels in this row to the left, then the right181 for (int ix = 0; ix < pixels->numCols; ix++) {182 float SN = pixels->data.F32[iy][ix] / sqrt(variance->data.F32[iy][ix]);183 if (SN < SN_LIMIT) continue;184 185 bool valid = false;186 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix] & crMask);187 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix-1] & crMask) : 0;188 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix+1] & crMask) : 0;189 190 if (!valid) continue;191 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;192 }180 // mark the pixels in this row to the left, then the right 181 for (int ix = 0; ix < pixels->numCols; ix++) { 182 float SN = pixels->data.F32[iy][ix] / sqrt(variance->data.F32[iy][ix]); 183 if (SN < SN_LIMIT) continue; 184 185 bool valid = false; 186 valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix] & crMask); 187 valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix-1] & crMask) : 0; 188 valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix+1] & crMask) : 0; 189 190 if (!valid) continue; 191 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask; 192 } 193 193 } 194 194 return true; … … 201 201 psVector *Ap = psVectorAllocEmpty (100, PS_TYPE_F32); 202 202 psVector *ApErr = psVectorAllocEmpty (100, PS_TYPE_F32); 203 203 204 204 psImageMaskType maskVal = options->maskVal | options->markVal; 205 205 … … 208 208 209 209 for (int i = 0; i < sources->n; i++) { 210 pmSource *source = sources->data[i];211 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;210 pmSource *source = sources->data[i]; 211 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 212 212 213 213 // replace object in image … … 216 216 } 217 217 218 // clear the mask bit and set the circular mask pixels219 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal));220 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", options->markVal);221 222 // XXX can we test if psfMag is set and calculate only if needed?223 pmSourceMagnitudes (source, psf, photMode, maskVal); // maskVal includes markVal224 225 // clear the mask bit 226 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal));218 // clear the mask bit and set the circular mask pixels 219 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal)); 220 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", options->markVal); 221 222 // XXX can we test if psfMag is set and calculate only if needed? 223 pmSourceMagnitudes (source, psf, photMode, maskVal); // maskVal includes markVal 224 225 // clear the mask bit 226 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal)); 227 227 228 228 // re-subtract the object, leave local sky 229 229 pmSourceSub (source, PM_MODEL_OP_FULL, options->maskVal); 230 230 231 float apMag = -2.5*log10(source->moments->Sum);232 float dMag = source->psfMag - apMag;233 234 psVectorAppend (Ap, 100, dMag);235 psVectorAppend (ApErr, 100, source->errMag);231 float apMag = -2.5*log10(source->moments->Sum); 232 float dMag = source->psfMag - apMag; 233 234 psVectorAppend (Ap, 100, dMag); 235 psVectorAppend (ApErr, 100, source->errMag); 236 236 } 237 237 … … 242 242 psVector *dAp = psVectorAlloc (Ap->n, PS_TYPE_F32); 243 243 for (int i = 0; i < Ap->n; i++) { 244 dAp->data.F32[i] = Ap->data.F32[i] - stats->robustMedian;244 dAp->data.F32[i] = Ap->data.F32[i] - stats->robustMedian; 245 245 } 246 246 … … 266 266 psLogMsg("psModules.objects", PS_LOG_INFO, "Source Size classifications: %4s %4s %4s %4s %4s %4s", "Npsf", "Next", "Nsat", "Ncr", "Nmiss", "Nskip"); 267 267 268 int nRegions = psMetadataLookupS32 (&status, re cipe, "PSF.CLUMP.NREGIONS");268 int nRegions = psMetadataLookupS32 (&status, readout->analysis, "PSF.CLUMP.NREGIONS"); 269 269 for (int i = 0; i < nRegions; i ++) { 270 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i);271 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);272 psAssert (regionMD, "regions must be defined by earlier call to psphotRoughClassRegion");273 274 psRegion *region = psMetadataLookupPtr (&status, regionMD, "REGION");275 psAssert (region, "regions must be defined by earlier call to psphotRoughClassRegion");276 277 // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y278 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); psAssert (status, "missing PSF.CLUMP.X");279 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); psAssert (status, "missing PSF.CLUMP.Y");280 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); psAssert (status, "missing PSF.CLUMP.DX");281 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); psAssert (status, "missing PSF.CLUMP.DY");282 283 if ((psfClump.X < 0) || (psfClump.Y < 0) || !psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) {284 psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);285 continue;286 }287 288 if (!psphotSourceClassRegion (region, &psfClump, sources, recipe, psf, options)) {289 psLogMsg ("psphot", 4, "Failed to determine source classification for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);290 continue;291 }292 } 270 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", i); 271 psMetadata *regionMD = psMetadataLookupPtr (&status, readout->analysis, regionName); 272 psAssert (regionMD, "regions must be defined by earlier call to psphotRoughClassRegion"); 273 274 psRegion *region = psMetadataLookupPtr (&status, regionMD, "REGION"); 275 psAssert (region, "regions must be defined by earlier call to psphotRoughClassRegion"); 276 277 // pull FWHM_X,Y from the recipe, use to define psfClump.X,Y 278 psfClump.X = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); psAssert (status, "missing PSF.CLUMP.X"); 279 psfClump.Y = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); psAssert (status, "missing PSF.CLUMP.Y"); 280 psfClump.dX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); psAssert (status, "missing PSF.CLUMP.DX"); 281 psfClump.dY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); psAssert (status, "missing PSF.CLUMP.DY"); 282 283 if ((psfClump.X < 0) || (psfClump.Y < 0) || !psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) { 284 psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1); 285 continue; 286 } 287 288 if (!psphotSourceClassRegion (region, &psfClump, sources, recipe, psf, options)) { 289 psLogMsg ("psphot", 4, "Failed to determine source classification for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1); 290 continue; 291 } 292 } 293 293 294 294 return true; … … 314 314 for (psS32 i = 0 ; i < sources->n ; i++) { 315 315 316 pmSource *source = (pmSource *) sources->data[i];317 318 // psfClumps are found for image subregions:319 // skip sources not in this region320 if (source->peak->x < region->x0) continue;321 if (source->peak->x >= region->x1) continue;322 if (source->peak->y < region->y0) continue;323 if (source->peak->y >= region->y1) continue;324 325 // skip source if it was already measured326 if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) {327 psTrace("psphot", 7, "Not calculating source size since it has already been measured\n");328 continue;329 }330 331 // source must have been subtracted332 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) {333 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED;334 psTrace("psphot", 7, "Not calculating source size since source is not subtracted\n");335 continue;336 }337 338 // we are basically classifying by moments; use the default if not found339 psAssert (source->moments, "why is this source missing moments?");340 if (source->mode & noMoments) { 341 Nskip ++;342 continue;343 }344 345 psF32 Mxx = source->moments->Mxx;346 psF32 Myy = source->moments->Myy;316 pmSource *source = (pmSource *) sources->data[i]; 317 318 // psfClumps are found for image subregions: 319 // skip sources not in this region 320 if (source->peak->x < region->x0) continue; 321 if (source->peak->x >= region->x1) continue; 322 if (source->peak->y < region->y0) continue; 323 if (source->peak->y >= region->y1) continue; 324 325 // skip source if it was already measured 326 if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) { 327 psTrace("psphot", 7, "Not calculating source size since it has already been measured\n"); 328 continue; 329 } 330 331 // source must have been subtracted 332 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) { 333 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED; 334 psTrace("psphot", 7, "Not calculating source size since source is not subtracted\n"); 335 continue; 336 } 337 338 // we are basically classifying by moments; use the default if not found 339 psAssert (source->moments, "why is this source missing moments?"); 340 if (source->mode & noMoments) { 341 Nskip ++; 342 continue; 343 } 344 345 psF32 Mxx = source->moments->Mxx; 346 psF32 Myy = source->moments->Myy; 347 347 348 348 // replace object in image … … 351 351 } 352 352 353 // clear the mask bit and set the circular mask pixels354 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal));355 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", options->markVal);356 357 // XXX can we test if psfMag is set and calculate only if needed?358 pmSourceMagnitudes (source, psf, photMode, maskVal); // maskVal includes markVal359 360 // clear the mask bit 361 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal));353 // clear the mask bit and set the circular mask pixels 354 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal)); 355 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", options->markVal); 356 357 // XXX can we test if psfMag is set and calculate only if needed? 358 pmSourceMagnitudes (source, psf, photMode, maskVal); // maskVal includes markVal 359 360 // clear the mask bit 361 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(options->markVal)); 362 362 363 363 // re-subtract the object, leave local sky 364 364 pmSourceSub (source, PM_MODEL_OP_FULL, options->maskVal); 365 365 366 float apMag = -2.5*log10(source->moments->Sum);367 float dMag = source->psfMag - apMag;368 float nSigma = (dMag - options->ApResid) / hypot(source->errMag, options->ApSysErr);369 370 source->extNsigma = nSigma;371 source->tmpFlags |= PM_SOURCE_TMPF_SIZE_MEASURED;372 373 // Anything within this region is a probably PSF-like object. Saturated stars may land374 // in this region, but are detected elsewhere on the basis of their peak value.375 bool isPSF = (fabs(nSigma) < options->nSigmaApResid) && (fabs(Mxx - psfClump->X) < options->nSigmaMoments*psfClump->dX) && (fabs(Myy - psfClump->Y) < options->nSigmaMoments*psfClump->dY);376 if (isPSF) {377 Npsf ++;378 continue;379 }380 381 // Defects may not always match CRs from peak curvature analysis382 // Defects may also be marked as SATSTAR -- XXX deactivate this flag?383 // XXX this rule is not great384 if ((Mxx < psfClump->X) || (Myy < psfClump->Y)) {385 source->mode |= PM_SOURCE_MODE_DEFECT;386 Ncr ++;387 continue;388 }389 390 // saturated star (determined in PSF fit). These may also be saturated galaxies, or391 // just large saturated regions.392 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 393 Nsat ++;394 continue;395 }396 397 // XXX allow the Mxx, Myy to be less than psfClump->X,Y (by some nSigma)?398 bool isEXT = (nSigma > options->nSigmaApResid) || ((Mxx > psfClump->X) && (Myy > psfClump->Y));399 if (isEXT) {400 source->mode |= PM_SOURCE_MODE_EXT_LIMIT;401 Next ++;402 continue;403 }404 405 psWarning ("sourse size was missed for %f,%f : %f %f -- %f\n", source->peak->xf, source->peak->yf, Mxx, Myy, nSigma);406 Nmiss ++;366 float apMag = -2.5*log10(source->moments->Sum); 367 float dMag = source->psfMag - apMag; 368 float nSigma = (dMag - options->ApResid) / hypot(source->errMag, options->ApSysErr); 369 370 source->extNsigma = nSigma; 371 source->tmpFlags |= PM_SOURCE_TMPF_SIZE_MEASURED; 372 373 // Anything within this region is a probably PSF-like object. Saturated stars may land 374 // in this region, but are detected elsewhere on the basis of their peak value. 375 bool isPSF = (fabs(nSigma) < options->nSigmaApResid) && (fabs(Mxx - psfClump->X) < options->nSigmaMoments*psfClump->dX) && (fabs(Myy - psfClump->Y) < options->nSigmaMoments*psfClump->dY); 376 if (isPSF) { 377 Npsf ++; 378 continue; 379 } 380 381 // Defects may not always match CRs from peak curvature analysis 382 // Defects may also be marked as SATSTAR -- XXX deactivate this flag? 383 // XXX this rule is not great 384 if ((Mxx < psfClump->X) || (Myy < psfClump->Y)) { 385 source->mode |= PM_SOURCE_MODE_DEFECT; 386 Ncr ++; 387 continue; 388 } 389 390 // saturated star (determined in PSF fit). These may also be saturated galaxies, or 391 // just large saturated regions. 392 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 393 Nsat ++; 394 continue; 395 } 396 397 // XXX allow the Mxx, Myy to be less than psfClump->X,Y (by some nSigma)? 398 bool isEXT = (nSigma > options->nSigmaApResid) || ((Mxx > psfClump->X) && (Myy > psfClump->Y)); 399 if (isEXT) { 400 source->mode |= PM_SOURCE_MODE_EXT_LIMIT; 401 Next ++; 402 continue; 403 } 404 405 psWarning ("sourse size was missed for %f,%f : %f %f -- %f\n", source->peak->xf, source->peak->yf, Mxx, Myy, nSigma); 406 Nmiss ++; 407 407 } 408 408 … … 417 417 // no longer used by psphot. 418 418 float psphotModelContour(const psImage *image, const psImage *variance, const psImage *mask, 419 psImageMaskType maskVal, const pmModel *model, float Ro)419 psImageMaskType maskVal, const pmModel *model, float Ro) 420 420 { 421 421 psF32 *PAR = model->params->data.F32; // Model parameters … … 432 432 float Q = Ro * PS_SQR(sxx) / (1.0 - PS_SQR(sxx * syy * sxy) / 4.0); 433 433 if (Q < 0.0) { 434 // ellipse is imaginary435 return NAN;434 // ellipse is imaginary 435 return NAN; 436 436 } 437 437 … … 441 441 442 442 for (int x = -radius; x <= radius; x++) { 443 // Polynomial coefficients444 // XXX Should we be using the centre of the pixel as x or x+0.5?445 float A = PS_SQR (1.0 / syy);446 float B = x * sxy;447 float C = PS_SQR (x / sxx) - Ro;448 float T = PS_SQR(B) - 4*A*C;449 if (T < 0.0) {450 continue;451 }452 453 // y position in source frame454 float yP = (-B + sqrt (T)) / (2.0 * A);455 float yM = (-B - sqrt (T)) / (2.0 * A);456 457 // Get the closest pixel positions (image frame)458 int xPix = x + PAR[PM_PAR_XPOS] - image->col0 + 0.5;459 int yPixM = yM + PAR[PM_PAR_YPOS] - image->row0 + 0.5;460 int yPixP = yP + PAR[PM_PAR_YPOS] - image->row0 + 0.5;461 462 if (xPix < 0 || xPix >= image->numCols) {463 continue;464 }465 466 if (yPixM >= 0 && yPixM < image->numRows &&467 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixM][xPix] & maskVal))) {468 float dSigma = image->data.F32[yPixM][xPix] / sqrtf(variance->data.F32[yPixM][xPix]);469 nSigma += dSigma;470 nPts++;471 }472 473 if (yPixM == yPixP) {474 continue;475 }476 477 if (yPixP >= 0 && yPixP < image->numRows &&478 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixP][xPix] & maskVal))) {479 float dSigma = image->data.F32[yPixP][xPix] / sqrtf(variance->data.F32[yPixP][xPix]);480 nSigma += dSigma;481 nPts++;482 }443 // Polynomial coefficients 444 // XXX Should we be using the centre of the pixel as x or x+0.5? 445 float A = PS_SQR (1.0 / syy); 446 float B = x * sxy; 447 float C = PS_SQR (x / sxx) - Ro; 448 float T = PS_SQR(B) - 4*A*C; 449 if (T < 0.0) { 450 continue; 451 } 452 453 // y position in source frame 454 float yP = (-B + sqrt (T)) / (2.0 * A); 455 float yM = (-B - sqrt (T)) / (2.0 * A); 456 457 // Get the closest pixel positions (image frame) 458 int xPix = x + PAR[PM_PAR_XPOS] - image->col0 + 0.5; 459 int yPixM = yM + PAR[PM_PAR_YPOS] - image->row0 + 0.5; 460 int yPixP = yP + PAR[PM_PAR_YPOS] - image->row0 + 0.5; 461 462 if (xPix < 0 || xPix >= image->numCols) { 463 continue; 464 } 465 466 if (yPixM >= 0 && yPixM < image->numRows && 467 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixM][xPix] & maskVal))) { 468 float dSigma = image->data.F32[yPixM][xPix] / sqrtf(variance->data.F32[yPixM][xPix]); 469 nSigma += dSigma; 470 nPts++; 471 } 472 473 if (yPixM == yPixP) { 474 continue; 475 } 476 477 if (yPixP >= 0 && yPixP < image->numRows && 478 !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixP][xPix] & maskVal))) { 479 float dSigma = image->data.F32[yPixP][xPix] / sqrtf(variance->data.F32[yPixP][xPix]); 480 nSigma += dSigma; 481 nPts++; 482 } 483 483 } 484 484 nSigma /= nPts; … … 491 491 // XXX use an internal flag to mark sources which have already been measured 492 492 for (int i = 0; i < sources->n; i++) { 493 pmSource *source = sources->data[i];494 495 // skip source if it was already measured496 if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) {497 psTrace("psphot", 7, "Not calculating source size since it has already been measured\n");498 continue;499 }500 501 // source must have been subtracted502 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) {503 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED;504 psTrace("psphot", 7, "Not calculating source size since source is not subtracted\n");505 continue;506 }507 508 psF32 **resid = source->pixels->data.F32;509 psF32 **variance = source->variance->data.F32;510 psImageMaskType **mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;511 512 // Integer position of peak513 int xPeak = source->peak->xf - source->pixels->col0 + 0.5;514 int yPeak = source->peak->yf - source->pixels->row0 + 0.5;515 516 // Skip sources which are too close to a boundary. These are mostly caught as DEFECT517 if (xPeak < 1 || xPeak > source->pixels->numCols - 2 ||518 yPeak < 1 || yPeak > source->pixels->numRows - 2) {519 psTrace("psphot", 7, "Not calculating crNsigma due to edge\n");520 continue;521 }522 523 // Skip sources with masked pixels. These are mostly caught as DEFECT524 bool keep = true;525 for (int iy = -1; (iy <= +1) && keep; iy++) {526 for (int ix = -1; (ix <= +1) && keep; ix++) {527 if (mask[yPeak+iy][xPeak+ix] & options->maskVal) {528 keep = false;529 }530 }531 }532 if (!keep) {533 psTrace("psphot", 7, "Not calculating crNsigma due to masked pixels\n");534 continue;535 }536 537 // Compare the central pixel with those on either side, for the four possible lines through it.538 539 // Soften variances (add systematic error)540 float softening = options->soft * PS_SQR(source->peak->flux); // Softening for variances541 542 // Across the middle: y = 0543 float cX = 2*resid[yPeak][xPeak] - resid[yPeak+0][xPeak-1] - resid[yPeak+0][xPeak+1];544 float dcX = 4*variance[yPeak][xPeak] + variance[yPeak+0][xPeak-1] + variance[yPeak+0][xPeak+1];545 float nX = cX / sqrtf(dcX + softening);546 547 // Up the centre: x = 0548 float cY = 2*resid[yPeak][xPeak] - resid[yPeak-1][xPeak+0] - resid[yPeak+1][xPeak+0];549 float dcY = 4*variance[yPeak][xPeak] + variance[yPeak-1][xPeak+0] + variance[yPeak+1][xPeak+0];550 float nY = cY / sqrtf(dcY + softening);551 552 // Diagonal: x = y553 float cL = 2*resid[yPeak][xPeak] - resid[yPeak-1][xPeak-1] - resid[yPeak+1][xPeak+1];554 float dcL = 4*variance[yPeak][xPeak] + variance[yPeak-1][xPeak-1] + variance[yPeak+1][xPeak+1];555 float nL = cL / sqrtf(dcL + softening);556 557 // Diagonal: x = - y558 float cR = 2*resid[yPeak][xPeak] - resid[yPeak+1][xPeak-1] - resid[yPeak-1][xPeak+1];559 float dcR = 4*variance[yPeak][xPeak] + variance[yPeak+1][xPeak-1] + variance[yPeak-1][xPeak+1];560 float nR = cR / sqrtf(dcR + softening);561 562 // P(chisq > chisq_obs; Ndof) = gamma_Q (Ndof/2, chisq/2)563 // Ndof = 4 ? (four measurements, no free parameters)564 // XXX this value is going to be biased low because of systematic errors.565 // we need to calibrate it somehow566 // source->psfProb = gsl_sf_gamma_inc_Q (2, 0.5*chisq);567 568 // not strictly accurate: overcounts the chisq contribution from the center pixel (by569 // factor of 4); also biases a bit low if any pixels are masked570 // XXX I am not sure I want to keep this value...571 source->psfChisq = PS_SQR(nX) + PS_SQR(nY) + PS_SQR(nL) + PS_SQR(nR);572 573 float fCR = 0.0;574 int nCR = 0;575 if (nX > 0.0) {576 fCR += nX;577 nCR ++;578 }579 if (nY > 0.0) {580 fCR += nY;581 nCR ++;582 }583 if (nL > 0.0) {584 fCR += nL;585 nCR ++;586 }587 if (nR > 0.0) {588 fCR += nR;589 nCR ++;590 }591 source->crNsigma = (nCR > 0) ? fCR / nCR : 0.0;592 source->tmpFlags |= PM_SOURCE_TMPF_SIZE_MEASURED;593 594 if (!isfinite(source->crNsigma)) {595 continue;596 }597 598 // this source is thought to be a cosmic ray. flag the detection and mask the pixels599 if (source->crNsigma > options->nSigmaCR) {600 source->mode |= PM_SOURCE_MODE_CR_LIMIT;601 // XXX still testing... : psphotMaskCosmicRay (readout->mask, source, maskVal, crMask);602 // XXX acting strange... psphotMaskCosmicRay_Old (source, maskVal, crMask);603 }493 pmSource *source = sources->data[i]; 494 495 // skip source if it was already measured 496 if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) { 497 psTrace("psphot", 7, "Not calculating source size since it has already been measured\n"); 498 continue; 499 } 500 501 // source must have been subtracted 502 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) { 503 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED; 504 psTrace("psphot", 7, "Not calculating source size since source is not subtracted\n"); 505 continue; 506 } 507 508 psF32 **resid = source->pixels->data.F32; 509 psF32 **variance = source->variance->data.F32; 510 psImageMaskType **mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 511 512 // Integer position of peak 513 int xPeak = source->peak->xf - source->pixels->col0 + 0.5; 514 int yPeak = source->peak->yf - source->pixels->row0 + 0.5; 515 516 // Skip sources which are too close to a boundary. These are mostly caught as DEFECT 517 if (xPeak < 1 || xPeak > source->pixels->numCols - 2 || 518 yPeak < 1 || yPeak > source->pixels->numRows - 2) { 519 psTrace("psphot", 7, "Not calculating crNsigma due to edge\n"); 520 continue; 521 } 522 523 // Skip sources with masked pixels. These are mostly caught as DEFECT 524 bool keep = true; 525 for (int iy = -1; (iy <= +1) && keep; iy++) { 526 for (int ix = -1; (ix <= +1) && keep; ix++) { 527 if (mask[yPeak+iy][xPeak+ix] & options->maskVal) { 528 keep = false; 529 } 530 } 531 } 532 if (!keep) { 533 psTrace("psphot", 7, "Not calculating crNsigma due to masked pixels\n"); 534 continue; 535 } 536 537 // Compare the central pixel with those on either side, for the four possible lines through it. 538 539 // Soften variances (add systematic error) 540 float softening = options->soft * PS_SQR(source->peak->flux); // Softening for variances 541 542 // Across the middle: y = 0 543 float cX = 2*resid[yPeak][xPeak] - resid[yPeak+0][xPeak-1] - resid[yPeak+0][xPeak+1]; 544 float dcX = 4*variance[yPeak][xPeak] + variance[yPeak+0][xPeak-1] + variance[yPeak+0][xPeak+1]; 545 float nX = cX / sqrtf(dcX + softening); 546 547 // Up the centre: x = 0 548 float cY = 2*resid[yPeak][xPeak] - resid[yPeak-1][xPeak+0] - resid[yPeak+1][xPeak+0]; 549 float dcY = 4*variance[yPeak][xPeak] + variance[yPeak-1][xPeak+0] + variance[yPeak+1][xPeak+0]; 550 float nY = cY / sqrtf(dcY + softening); 551 552 // Diagonal: x = y 553 float cL = 2*resid[yPeak][xPeak] - resid[yPeak-1][xPeak-1] - resid[yPeak+1][xPeak+1]; 554 float dcL = 4*variance[yPeak][xPeak] + variance[yPeak-1][xPeak-1] + variance[yPeak+1][xPeak+1]; 555 float nL = cL / sqrtf(dcL + softening); 556 557 // Diagonal: x = - y 558 float cR = 2*resid[yPeak][xPeak] - resid[yPeak+1][xPeak-1] - resid[yPeak-1][xPeak+1]; 559 float dcR = 4*variance[yPeak][xPeak] + variance[yPeak+1][xPeak-1] + variance[yPeak-1][xPeak+1]; 560 float nR = cR / sqrtf(dcR + softening); 561 562 // P(chisq > chisq_obs; Ndof) = gamma_Q (Ndof/2, chisq/2) 563 // Ndof = 4 ? (four measurements, no free parameters) 564 // XXX this value is going to be biased low because of systematic errors. 565 // we need to calibrate it somehow 566 // source->psfProb = gsl_sf_gamma_inc_Q (2, 0.5*chisq); 567 568 // not strictly accurate: overcounts the chisq contribution from the center pixel (by 569 // factor of 4); also biases a bit low if any pixels are masked 570 // XXX I am not sure I want to keep this value... 571 source->psfChisq = PS_SQR(nX) + PS_SQR(nY) + PS_SQR(nL) + PS_SQR(nR); 572 573 float fCR = 0.0; 574 int nCR = 0; 575 if (nX > 0.0) { 576 fCR += nX; 577 nCR ++; 578 } 579 if (nY > 0.0) { 580 fCR += nY; 581 nCR ++; 582 } 583 if (nL > 0.0) { 584 fCR += nL; 585 nCR ++; 586 } 587 if (nR > 0.0) { 588 fCR += nR; 589 nCR ++; 590 } 591 source->crNsigma = (nCR > 0) ? fCR / nCR : 0.0; 592 source->tmpFlags |= PM_SOURCE_TMPF_SIZE_MEASURED; 593 594 if (!isfinite(source->crNsigma)) { 595 continue; 596 } 597 598 // this source is thought to be a cosmic ray. flag the detection and mask the pixels 599 if (source->crNsigma > options->nSigmaCR) { 600 source->mode |= PM_SOURCE_MODE_CR_LIMIT; 601 // XXX still testing... : psphotMaskCosmicRay (readout->mask, source, maskVal, crMask); 602 // XXX acting strange... psphotMaskCosmicRay_Old (source, maskVal, crMask); 603 } 604 604 } 605 605 606 606 // now that we have masked pixels associated with CRs, we can grow the mask 607 607 if (options->grow > 0) { 608 bool oldThreads = psImageConvolveSetThreads(true); // Old value of threading for psImageConvolveMask609 psImage *newMask = psImageConvolveMask(NULL, readout->mask, options->crMask, options->crMask, -options->grow, options->grow, -options->grow, options->grow);610 psImageConvolveSetThreads(oldThreads);611 if (!newMask) {612 psError(PS_ERR_UNKNOWN, false, "Unable to grow CR mask");613 return false;614 }615 psFree(readout->mask);616 readout->mask = newMask;608 bool oldThreads = psImageConvolveSetThreads(true); // Old value of threading for psImageConvolveMask 609 psImage *newMask = psImageConvolveMask(NULL, readout->mask, options->crMask, options->crMask, -options->grow, options->grow, -options->grow, options->grow); 610 psImageConvolveSetThreads(oldThreads); 611 if (!newMask) { 612 psError(PS_ERR_UNKNOWN, false, "Unable to grow CR mask"); 613 return false; 614 } 615 psFree(readout->mask); 616 readout->mask = newMask; 617 617 } 618 618 return true; -
branches/eam_branches/20090820/psphot/src/psphotSourceStats.c
r25766 r25870 1 1 # include "psphotInternal.h" 2 2 3 bool psphotSetMomentsWindow (psMetadata *recipe, ps Array *sources);3 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources); 4 4 5 5 psArray *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections, bool setWindow) { … … 68 68 69 69 if (setWindow) { 70 if (!psphotSetMomentsWindow(recipe, sources)) {71 psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!");72 return NULL;73 }70 if (!psphotSetMomentsWindow(recipe, readout->analysis, sources)) { 71 psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!"); 72 return NULL; 73 } 74 74 } 75 75 … … 242 242 243 243 // this function attempts to iteratively determine the best value for sigma of the moments weighting Gaussian 244 bool psphotSetMomentsWindow (psMetadata *recipe, ps Array *sources) {244 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources) { 245 245 246 246 bool status; … … 259 259 for (int i = 0; i < 4; i++) { 260 260 261 // XXX move max source number to config262 for (int j = 0; (j < sources->n) && (j < 400); j++) {263 264 pmSource *source = sources->data[j];265 psAssert (source->moments, "force moments to exist");266 source->moments->nPixels = 0;267 268 // skip faint sources for moments measurement269 if (source->peak->SN < MIN_SN) {270 continue;271 }272 273 // measure basic source moments (no S/N clipping on input pixels)274 status = pmSourceMoments (source, 4*sigma[i], sigma[i], 0.0);275 }276 277 // choose a grid scale that is a fixed fraction of the psf sigma^2278 psMetadataAddF32(recipe, PS_LIST_TAIL, "PSF_CLUMP_GRID_SCALE", PS_META_REPLACE, "clump grid", 0.1*PS_SQR(sigma[i]));279 psMetadataAddF32(recipe, PS_LIST_TAIL, "MOMENTS_SX_MAX", PS_META_REPLACE, "moments limit", 2.0*PS_SQR(sigma[i]));280 psMetadataAddF32(recipe, PS_LIST_TAIL, "MOMENTS_SY_MAX", PS_META_REPLACE, "moments limit", 2.0*PS_SQR(sigma[i]));281 282 // determine the PSF parameters from the source moment values283 pmPSFClump psfClump = pmSourcePSFClump (NULL, sources, recipe);284 psLogMsg ("psphot", 3, "radius %.1f, nStars: %d, nSigma: %5.2f, X, Y: %f, %f (%f, %f)\n", sigma[i], psfClump.nStars, psfClump.nSigma, psfClump.X, psfClump.Y, sqrt(psfClump.X) / sigma[i], sqrt(psfClump.Y) / sigma[i]);285 286 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1);287 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, "PSF.CLUMP.REGION.000");288 if (!regionMD) {289 regionMD = psMetadataAlloc();290 psMetadataAddMetadata (recipe, PS_LIST_TAIL, "PSF.CLUMP.REGION.000", PS_META_REPLACE, "psf clump region", regionMD);291 psFree (regionMD);292 }293 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X);294 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y);295 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX);296 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);297 298 // psphotVisualPlotMoments (recipe, sources);299 300 Sout[i] = sqrt(0.5*(psfClump.X + psfClump.Y)) / sigma[i];261 // XXX move max source number to config 262 for (int j = 0; (j < sources->n) && (j < 400); j++) { 263 264 pmSource *source = sources->data[j]; 265 psAssert (source->moments, "force moments to exist"); 266 source->moments->nPixels = 0; 267 268 // skip faint sources for moments measurement 269 if (source->peak->SN < MIN_SN) { 270 continue; 271 } 272 273 // measure basic source moments (no S/N clipping on input pixels) 274 status = pmSourceMoments (source, 4*sigma[i], sigma[i], 0.0); 275 } 276 277 // choose a grid scale that is a fixed fraction of the psf sigma^2 278 psMetadataAddF32(recipe, PS_LIST_TAIL, "PSF_CLUMP_GRID_SCALE", PS_META_REPLACE, "clump grid", 0.1*PS_SQR(sigma[i])); 279 psMetadataAddF32(recipe, PS_LIST_TAIL, "MOMENTS_SX_MAX", PS_META_REPLACE, "moments limit", 2.0*PS_SQR(sigma[i])); 280 psMetadataAddF32(recipe, PS_LIST_TAIL, "MOMENTS_SY_MAX", PS_META_REPLACE, "moments limit", 2.0*PS_SQR(sigma[i])); 281 282 // determine the PSF parameters from the source moment values 283 pmPSFClump psfClump = pmSourcePSFClump (NULL, sources, recipe); 284 psLogMsg ("psphot", 3, "radius %.1f, nStars: %d, nSigma: %5.2f, X, Y: %f, %f (%f, %f)\n", sigma[i], psfClump.nStars, psfClump.nSigma, psfClump.X, psfClump.Y, sqrt(psfClump.X) / sigma[i], sqrt(psfClump.Y) / sigma[i]); 285 286 psMetadataAddS32 (analysis, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", 1); 287 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, "PSF.CLUMP.REGION.000"); 288 if (!regionMD) { 289 regionMD = psMetadataAlloc(); 290 psMetadataAddMetadata (analysis, PS_LIST_TAIL, "PSF.CLUMP.REGION.000", PS_META_REPLACE, "psf clump region", regionMD); 291 psFree (regionMD); 292 } 293 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.X", PS_META_REPLACE, "psf clump center", psfClump.X); 294 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.Y", PS_META_REPLACE, "psf clump center", psfClump.Y); 295 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DX", PS_META_REPLACE, "psf clump center", psfClump.dX); 296 psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY); 297 298 // psphotVisualPlotMoments (recipe, sources); 299 300 Sout[i] = sqrt(0.5*(psfClump.X + psfClump.Y)) / sigma[i]; 301 301 } 302 302 … … 307 307 float maxS = Sout[0]; 308 308 for (int i = 0; i < 4; i++) { 309 minS = PS_MIN(Sout[i], minS);310 maxS = PS_MAX(Sout[i], maxS);309 minS = PS_MIN(Sout[i], minS); 310 maxS = PS_MAX(Sout[i], maxS); 311 311 } 312 312 if (minS > 0.65) Sigma = sigma[3]; … … 314 314 315 315 for (int i = 0; i < 3; i++) { 316 if ((Sout[i] > 0.65) && (Sout[i+1] > 0.65)) continue;317 if ((Sout[i] < 0.65) && (Sout[i+1] < 0.65)) continue;318 Sigma = sigma[i] + (0.65 - Sout[i])*(sigma[i+1] - sigma[i])/(Sout[i+1] - Sout[i]);316 if ((Sout[i] > 0.65) && (Sout[i+1] > 0.65)) continue; 317 if ((Sout[i] < 0.65) && (Sout[i+1] < 0.65)) continue; 318 Sigma = sigma[i] + (0.65 - Sout[i])*(sigma[i+1] - sigma[i])/(Sout[i+1] - Sout[i]); 319 319 } 320 320 psAssert (isfinite(Sigma), "did we miss a case?"); 321 321 322 322 // choose a grid scale that is a fixed fraction of the psf sigma^2 323 323 psMetadataAddF32(recipe, PS_LIST_TAIL, "PSF_CLUMP_GRID_SCALE", PS_META_REPLACE, "clump grid", 0.1*PS_SQR(Sigma)); -
branches/eam_branches/20090820/psphot/src/psphotVisual.c
r25766 r25870 28 28 switch (channel) { 29 29 case 1: 30 if (kapa1 == -1) {31 kapa1 = KapaOpenNamedSocket ("kapa", "psphot:images");32 if (kapa1 == -1) {33 fprintf (stderr, "failure to open kapa; visual mode disabled\n");34 pmVisualSetVisual(false);35 }36 }37 return kapa1;30 if (kapa1 == -1) { 31 kapa1 = KapaOpenNamedSocket ("kapa", "psphot:images"); 32 if (kapa1 == -1) { 33 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 34 pmVisualSetVisual(false); 35 } 36 } 37 return kapa1; 38 38 case 2: 39 if (kapa2 == -1) {40 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:plots");41 if (kapa2 == -1) {42 fprintf (stderr, "failure to open kapa; visual mode disabled\n");43 pmVisualSetVisual(false);44 }45 }46 return kapa2;39 if (kapa2 == -1) { 40 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 41 if (kapa2 == -1) { 42 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 43 pmVisualSetVisual(false); 44 } 45 } 46 return kapa2; 47 47 case 3: 48 if (kapa3 == -1) {49 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:stamps");50 if (kapa3 == -1) {51 fprintf (stderr, "failure to open kapa; visual mode disabled\n");52 pmVisualSetVisual(false);53 }54 }55 return kapa3;48 if (kapa3 == -1) { 49 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:stamps"); 50 if (kapa3 == -1) { 51 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 52 pmVisualSetVisual(false); 53 } 54 } 55 return kapa3; 56 56 default: 57 psAbort ("unknown kapa channel");57 psAbort ("unknown kapa channel"); 58 58 } 59 59 psAbort ("unknown kapa channel"); … … 315 315 316 316 // draw the top 317 // XXX need to allow top (and bottom) to have more than one span317 // XXX need to allow top (and bottom) to have more than one span 318 318 span = footprint->spans->data[0]; 319 319 overlay[Noverlay].type = KII_OVERLAY_LINE; … … 448 448 } 449 449 450 bool psphotVisualPlotMoments (psMetadata *recipe, ps Array *sources) {450 bool psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources) { 451 451 452 452 bool status; … … 469 469 float Ymin = 1000.0, Ymax = 0.0; 470 470 { 471 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");471 int nRegions = psMetadataLookupS32 (&status, analysis, "PSF.CLUMP.NREGIONS"); 472 472 for (int n = 0; n < nRegions; n++) { 473 473 474 474 char regionName[64]; 475 475 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n); 476 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);477 478 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X");476 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 477 478 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 479 479 float psfY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); 480 480 float psfdX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); 481 481 float psfdY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); 482 482 483 float X0 = psfX - 4.0*psfdX;484 float X1 = psfX + 4.0*psfdX;485 float Y0 = psfY - 4.0*psfdY;486 float Y1 = psfY + 4.0*psfdY;487 488 if (isfinite(X0)) { Xmin = PS_MIN(Xmin, X0); }489 if (isfinite(X1)) { Xmax = PS_MAX(Xmax, X1); }490 if (isfinite(Y0)) { Ymin = PS_MIN(Ymin, Y0); }491 if (isfinite(Y1)) { Ymax = PS_MAX(Ymax, Y1); }492 } 493 } 494 Xmin = PS_MAX(Xmin, -0.1); 495 Ymin = PS_MAX(Ymin, -0.1); 483 float X0 = psfX - 4.0*psfdX; 484 float X1 = psfX + 4.0*psfdX; 485 float Y0 = psfY - 4.0*psfdY; 486 float Y1 = psfY + 4.0*psfdY; 487 488 if (isfinite(X0)) { Xmin = PS_MIN(Xmin, X0); } 489 if (isfinite(X1)) { Xmax = PS_MAX(Xmax, X1); } 490 if (isfinite(Y0)) { Ymin = PS_MIN(Ymin, Y0); } 491 if (isfinite(Y1)) { Ymax = PS_MAX(Ymax, Y1); } 492 } 493 } 494 Xmin = PS_MAX(Xmin, -0.1); 495 Ymin = PS_MAX(Ymin, -0.1); 496 496 497 497 // storage vectors for data to be plotted … … 653 653 psVector *yLimit = psVectorAlloc (120, PS_TYPE_F32); 654 654 655 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");656 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA");655 int nRegions = psMetadataLookupS32 (&status, analysis, "PSF.CLUMP.NREGIONS"); 656 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, analysis, "PSF_CLUMP_NSIGMA"); 657 657 658 658 graphdata.color = KapaColorByName ("blue"); 659 659 graphdata.style = 0; 660 660 661 graphdata.xmin = Xmin;662 graphdata.ymin = Ymin;663 graphdata.xmax = Xmax;664 graphdata.ymax = Ymax;665 KapaSetLimits (myKapa, &graphdata);661 graphdata.xmin = Xmin; 662 graphdata.ymin = Ymin; 663 graphdata.xmax = Xmax; 664 graphdata.ymax = Ymax; 665 KapaSetLimits (myKapa, &graphdata); 666 666 667 667 for (int n = 0; n < nRegions; n++) { … … 669 669 char regionName[64]; 670 670 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n); 671 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);671 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 672 672 673 673 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); … … 926 926 if (Xo == 0) { 927 927 // place source alone on this row 928 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);929 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);928 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 929 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 930 930 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 931 931 932 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);932 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 933 933 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 934 934 935 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);935 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 936 936 937 937 Yo += DY; … … 943 943 Xo = 0; 944 944 945 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);946 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);945 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 946 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 947 947 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 948 948 949 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);949 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 950 950 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 951 951 952 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);952 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 953 953 954 954 Xo = DX; … … 957 957 } else { 958 958 // extend this row 959 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);960 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);959 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 960 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 961 961 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 962 962 963 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);963 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 964 964 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 965 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);965 if (!subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 966 966 967 967 Xo += DX; … … 1020 1020 pmSource *source = sources->data[i]; 1021 1021 1022 // only show "real" saturated stars (not defects)1022 // only show "real" saturated stars (not defects) 1023 1023 if (!(source->mode & PM_SOURCE_MODE_SATSTAR)) continue;; 1024 1024 if (source->mode & PM_SOURCE_MODE_DEFECT) continue;; … … 1065 1065 pmSource *source = sources->data[i]; 1066 1066 1067 // only show "real" saturated stars (not defects)1067 // only show "real" saturated stars (not defects) 1068 1068 if (!(source->mode & PM_SOURCE_MODE_SATSTAR)) continue;; 1069 1069 if (source->mode & PM_SOURCE_MODE_DEFECT) continue;; 1070 nSAT ++;1070 nSAT ++; 1071 1071 1072 1072 if (Xo + DX > NX) { … … 1074 1074 if (Xo == 0) { 1075 1075 // place source alone on this row 1076 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);1077 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);1076 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 1077 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 1078 1078 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1079 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);1079 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 1080 1080 1081 1081 Yo += DY; … … 1087 1087 Xo = 0; 1088 1088 1089 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);1090 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);1089 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 1090 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 1091 1091 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1092 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);1092 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 1093 1093 1094 1094 Xo = DX; … … 1097 1097 } else { 1098 1098 // extend this row 1099 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);1100 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);1099 bool subtracted = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 1100 if (subtracted) pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 1101 1101 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1102 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);1102 if (subtracted) pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 1103 1103 1104 1104 Xo += DX; … … 1406 1406 1407 1407 // if (source->type != type) continue; 1408 if (mode) {1409 if (keep) {1410 if (!(source->mode & mode)) continue;1411 } else {1412 if (source->mode & mode) continue;1413 }1414 }1408 if (mode) { 1409 if (keep) { 1410 if (!(source->mode & mode)) continue; 1411 } else { 1412 if (source->mode & mode) continue; 1413 } 1414 } 1415 1415 1416 1416 pmMoments *moments = source->moments; … … 1463 1463 } 1464 1464 1465 bool psphotVisualPlotSourceSize (psMetadata *recipe, ps Array *sources) {1465 bool psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources) { 1466 1466 1467 1467 bool status; … … 1482 1482 float Ymin = 1000.0, Ymax = 0.0; 1483 1483 { 1484 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");1484 int nRegions = psMetadataLookupS32 (&status, analysis, "PSF.CLUMP.NREGIONS"); 1485 1485 for (int n = 0; n < nRegions; n++) { 1486 1486 1487 1487 char regionName[64]; 1488 1488 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n); 1489 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);1490 1491 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X");1489 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 1490 1491 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 1492 1492 float psfY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); 1493 1493 float psfdX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); 1494 1494 float psfdY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); 1495 1495 1496 float X0 = psfX - 10.0*psfdX;1497 float X1 = psfX + 10.0*psfdX;1498 float Y0 = psfY - 10.0*psfdY;1499 float Y1 = psfY + 10.0*psfdY;1500 1501 if (isfinite(X0)) { Xmin = PS_MIN(Xmin, X0); }1502 if (isfinite(X1)) { Xmax = PS_MAX(Xmax, X1); }1503 if (isfinite(Y0)) { Ymin = PS_MIN(Ymin, Y0); }1504 if (isfinite(Y1)) { Ymax = PS_MAX(Ymax, Y1); }1505 } 1506 } 1507 Xmin = PS_MAX(Xmin, -0.1); 1508 Ymin = PS_MAX(Ymin, -0.1); 1496 float X0 = psfX - 10.0*psfdX; 1497 float X1 = psfX + 10.0*psfdX; 1498 float Y0 = psfY - 10.0*psfdY; 1499 float Y1 = psfY + 10.0*psfdY; 1500 1501 if (isfinite(X0)) { Xmin = PS_MIN(Xmin, X0); } 1502 if (isfinite(X1)) { Xmax = PS_MAX(Xmax, X1); } 1503 if (isfinite(Y0)) { Ymin = PS_MIN(Ymin, Y0); } 1504 if (isfinite(Y1)) { Ymax = PS_MAX(Ymax, Y1); } 1505 } 1506 } 1507 Xmin = PS_MAX(Xmin, -0.1); 1508 Ymin = PS_MAX(Ymin, -0.1); 1509 1509 1510 1510 // storage vectors for data to be plotted … … 1544 1544 if (source->moments == NULL) continue; 1545 1545 1546 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) { 1547 xCR->data.F32[nCR] = source->moments->Mxx;1548 yCR->data.F32[nCR] = source->moments->Myy;1549 mCR->data.F32[nCR] = -2.5*log10(source->moments->Sum);1550 sCR->data.F32[nCR] = source->extNsigma;1551 nCR++;1552 }1553 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 1554 xSAT->data.F32[nSAT] = source->moments->Mxx;1555 ySAT->data.F32[nSAT] = source->moments->Myy;1556 mSAT->data.F32[nSAT] = -2.5*log10(source->moments->Sum);1557 sSAT->data.F32[nSAT] = source->extNsigma;1558 nSAT++;1559 }1560 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 1561 xEXT->data.F32[nEXT] = source->moments->Mxx;1562 yEXT->data.F32[nEXT] = source->moments->Myy;1563 mEXT->data.F32[nEXT] = -2.5*log10(source->moments->Sum);1564 sEXT->data.F32[nEXT] = source->extNsigma;1565 nEXT++;1566 continue;1567 }1568 if (source->mode & PM_SOURCE_MODE_DEFECT) { 1569 xDEF->data.F32[nDEF] = source->moments->Mxx;1570 yDEF->data.F32[nDEF] = source->moments->Myy;1571 mDEF->data.F32[nDEF] = -2.5*log10(source->moments->Sum);1572 sDEF->data.F32[nDEF] = source->extNsigma;1573 nDEF++;1574 continue;1575 }1576 if ((source->mode & PM_SOURCE_MODE_CR_LIMIT) || (source->mode & PM_SOURCE_MODE_SATSTAR)) {1577 continue;1578 }1579 xPSF->data.F32[nPSF] = source->moments->Mxx;1580 yPSF->data.F32[nPSF] = source->moments->Myy;1581 mPSF->data.F32[nPSF] = -2.5*log10(source->moments->Sum);1582 sPSF->data.F32[nPSF] = source->extNsigma;1583 nPSF++;1546 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) { 1547 xCR->data.F32[nCR] = source->moments->Mxx; 1548 yCR->data.F32[nCR] = source->moments->Myy; 1549 mCR->data.F32[nCR] = -2.5*log10(source->moments->Sum); 1550 sCR->data.F32[nCR] = source->extNsigma; 1551 nCR++; 1552 } 1553 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 1554 xSAT->data.F32[nSAT] = source->moments->Mxx; 1555 ySAT->data.F32[nSAT] = source->moments->Myy; 1556 mSAT->data.F32[nSAT] = -2.5*log10(source->moments->Sum); 1557 sSAT->data.F32[nSAT] = source->extNsigma; 1558 nSAT++; 1559 } 1560 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 1561 xEXT->data.F32[nEXT] = source->moments->Mxx; 1562 yEXT->data.F32[nEXT] = source->moments->Myy; 1563 mEXT->data.F32[nEXT] = -2.5*log10(source->moments->Sum); 1564 sEXT->data.F32[nEXT] = source->extNsigma; 1565 nEXT++; 1566 continue; 1567 } 1568 if (source->mode & PM_SOURCE_MODE_DEFECT) { 1569 xDEF->data.F32[nDEF] = source->moments->Mxx; 1570 yDEF->data.F32[nDEF] = source->moments->Myy; 1571 mDEF->data.F32[nDEF] = -2.5*log10(source->moments->Sum); 1572 sDEF->data.F32[nDEF] = source->extNsigma; 1573 nDEF++; 1574 continue; 1575 } 1576 if ((source->mode & PM_SOURCE_MODE_CR_LIMIT) || (source->mode & PM_SOURCE_MODE_SATSTAR)) { 1577 continue; 1578 } 1579 xPSF->data.F32[nPSF] = source->moments->Mxx; 1580 yPSF->data.F32[nPSF] = source->moments->Myy; 1581 mPSF->data.F32[nPSF] = -2.5*log10(source->moments->Sum); 1582 sPSF->data.F32[nPSF] = source->extNsigma; 1583 nPSF++; 1584 1584 } 1585 1585 xSAT->n = nSAT; … … 1861 1861 psVector *yLimit = psVectorAlloc (120, PS_TYPE_F32); 1862 1862 1863 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");1864 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA");1863 int nRegions = psMetadataLookupS32 (&status, analysis, "PSF.CLUMP.NREGIONS"); 1864 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, analysis, "PSF_CLUMP_NSIGMA"); 1865 1865 1866 1866 graphdata.color = KapaColorByName ("blue"); 1867 1867 graphdata.style = 0; 1868 1868 1869 graphdata.xmin = Xmin;1870 graphdata.ymin = Ymin;1871 graphdata.xmax = Xmax;1872 graphdata.ymax = Ymax;1873 KapaSetLimits (myKapa, &graphdata);1869 graphdata.xmin = Xmin; 1870 graphdata.ymin = Ymin; 1871 graphdata.xmax = Xmax; 1872 graphdata.ymax = Ymax; 1873 KapaSetLimits (myKapa, &graphdata); 1874 1874 1875 1875 for (int n = 0; n < nRegions; n++) { … … 1877 1877 char regionName[64]; 1878 1878 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n); 1879 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);1879 psMetadata *regionMD = psMetadataLookupPtr (&status, analysis, regionName); 1880 1880 1881 1881 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); … … 2069 2069 2070 2070 for (int i = 0; i < sources->n; i++) { 2071 pmSource *source = sources->data[i];2072 2073 if (!source) continue;2074 if (!source->extpars) continue;2075 if (!source->extpars->profile) continue;2076 if (!source->extpars->petrosian_80) continue;2077 2078 pmSourceRadialProfile *profile = source->extpars->profile;2079 pmSourceExtendedFlux *petrosian = source->extpars->petrosian_80;2080 2081 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;2082 overlay[Noverlay].x = source->peak->xf;2083 overlay[Noverlay].y = source->peak->yf;2084 overlay[Noverlay].dx = 2.0*petrosian->radius;2085 overlay[Noverlay].dy = 2.0*petrosian->radius*profile->axes.minor/profile->axes.major;2086 overlay[Noverlay].angle = profile->axes.theta * PS_DEG_RAD;2087 overlay[Noverlay].text = NULL;2088 Noverlay ++;2071 pmSource *source = sources->data[i]; 2072 2073 if (!source) continue; 2074 if (!source->extpars) continue; 2075 if (!source->extpars->profile) continue; 2076 if (!source->extpars->petrosian_80) continue; 2077 2078 pmSourceRadialProfile *profile = source->extpars->profile; 2079 pmSourceExtendedFlux *petrosian = source->extpars->petrosian_80; 2080 2081 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 2082 overlay[Noverlay].x = source->peak->xf; 2083 overlay[Noverlay].y = source->peak->yf; 2084 overlay[Noverlay].dx = 2.0*petrosian->radius; 2085 overlay[Noverlay].dy = 2.0*petrosian->radius*profile->axes.minor/profile->axes.major; 2086 overlay[Noverlay].angle = profile->axes.theta * PS_DEG_RAD; 2087 overlay[Noverlay].text = NULL; 2088 Noverlay ++; 2089 2089 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 2090 2090 2091 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;2092 overlay[Noverlay].x = source->peak->xf;2093 overlay[Noverlay].y = source->peak->yf;2094 overlay[Noverlay].dx = 4.0*petrosian->radius;2095 overlay[Noverlay].dy = 4.0*petrosian->radius*profile->axes.minor/profile->axes.major;2096 overlay[Noverlay].angle = profile->axes.theta * PS_DEG_RAD;2097 overlay[Noverlay].text = NULL;2098 Noverlay ++;2091 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 2092 overlay[Noverlay].x = source->peak->xf; 2093 overlay[Noverlay].y = source->peak->yf; 2094 overlay[Noverlay].dx = 4.0*petrosian->radius; 2095 overlay[Noverlay].dy = 4.0*petrosian->radius*profile->axes.minor/profile->axes.major; 2096 overlay[Noverlay].angle = profile->axes.theta * PS_DEG_RAD; 2097 overlay[Noverlay].text = NULL; 2098 Noverlay ++; 2099 2099 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 2100 2100 } -
branches/eam_branches/20090820/pstamp/scripts/pstampparse.pl
r25766 r25870 72 72 } 73 73 74 # just deal with these arguments once and for all 75 $pstamptool .= " -dbname $dbname" if $dbname; 76 $pstamptool .= " -dbserver $dbserver" if $dbserver; 77 74 78 # list_job is a deugging mode 75 79 $no_update = 1 if $mode eq "list_job"; … … 105 109 if ($req_id and !$no_update) { 106 110 my $command = "$pstamptool -listreq -name $req_name -not_req_id $req_id"; 107 $command .= " -dbname $dbname" if $dbname;108 $command .= " -dbserver $dbserver" if $dbserver;109 111 # no verbose so that error message about request not found doesn't appear in parse_error.txt 110 112 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 127 129 my $command = "$pstamptool -updatereq -req_id $req_id -name $req_name"; 128 130 $command .= " -outProduct $product"; 129 $command .= " -dbname $dbname" if $dbname;130 $command .= " -dbserver $dbserver" if $dbserver;131 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 132 run(command => $command, verbose => $verbose); … … 195 195 my $mjd_max = $row->{MJD_MAX}; 196 196 my $label = $row->{LABEL}; 197 my $x = $row->{CENTER_X}; 198 my $y = $row->{CENTER_Y}; 197 199 198 200 my $option_mask= $row->{OPTION_MASK}; … … 205 207 206 208 if (!$skycenter and !$search_component) { 207 print STDERR "COMPONENT must be specified for pixel coordinate ROI \n" if $verbose;209 print STDERR "COMPONENT must be specified for pixel coordinate ROI center\n" if $verbose; 208 210 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 209 211 $num_jobs++; … … 213 215 $search_component = "" if $search_component eq "all"; 214 216 215 if (( $job_type eq "stamp") and ! validROI($row)) {217 if ((($job_type eq "stamp") or ($req_type eq "bycoord")) and ! validROI($row)) { 216 218 print STDERR "invalid ROI for row $rownum\n" if $verbose; 217 219 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); … … 262 264 next; 263 265 } 264 print STDERR "lookup bycoord is not yet implemented" if $verbose;265 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);266 $num_jobs++;267 next;268 } else {269 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this270 # request specification. An array reference is returned.271 my ($x, $y);272 273 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component,266 if ($stage eq "stack") { 267 print STDERR "lookup bycoord is not yet implemented for stage stack" if $verbose; 268 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 269 $num_jobs++; 270 next; 271 } 272 } 273 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this 274 # request specification. An array reference is returned. 275 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component, 274 276 $inverse, $need_magic, $x, $y, $mjd_min, $mjd_max, $filter, $label, $verbose); 275 277 276 if (!$imageList or !@$imageList) { 277 print STDERR "no matching images found for row $rownum\n" if $verbose; 278 # note in this case queueJobs inserts the fake job for these rows 279 } 280 $row->{need_magic} = $need_magic; 281 push @rowList, $row; 282 } 278 if (!$imageList or !@$imageList) { 279 print STDERR "no matching images found for row $rownum\n" if $verbose; 280 # note in this case queueJobs inserts the fake job for these rows 281 } 282 $row->{need_magic} = $need_magic; 283 push @rowList, $row; 283 284 } 284 285 … … 397 398 my $newState = "run"; 398 399 my $fault = 0; 399 400 if (($stage ne 'stack') and ($stage ne 'raw')) { 401 if (($image->{state} eq 'goto_purged') or ($image->{data_state} eq 'purged')) { 400 my $dep_id; 401 402 if ($stage ne 'raw') { 403 my $run_state = $image->{state}; 404 my $data_state = $image->{data_state}; 405 $data_state = $run_state if $stage eq "stack"; 406 if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or 407 ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) { 408 # image is gone and it's not coming back 402 409 $newState = 'stop'; 403 410 $fault = $PSTAMP_GONE; 404 } elsif (($image->{data_state} ne 'full') or ($image->{state} ne 'full' )) { 405 # XXX here is where we need to queue an update job 406 # for now just say that the image is not available 407 $newState = 'stop'; 408 $fault = $PSTAMP_NOT_AVAILABLE; 411 } elsif (($data_state ne 'full') or ($run_state ne 'full' )) { 412 # don't wait for update unless the caller asks us to 413 if (!($option_mask & $PSTAMP_WAIT_FOR_UPDATE)) { 414 $newState = 'stop'; 415 $fault = $PSTAMP_NOT_AVAILABLE; 416 } else { 417 # cause the image to be re-made 418 # set up to queue an update run 419 queue_update_run(\$newState, \$fault, \$dep_id, $image->{image_db}, 420 $run_state, $stage, $image->{stage_id}, $need_magic, $image->{label}); 421 } 409 422 } 410 423 } … … 415 428 $command .= " -fault $fault" if $fault; 416 429 $command .= " -exp_id $exp_id" if $exp_id; 417 $command .= " -dbname $dbname" if $dbname; 418 $command .= " -dbserver $dbserver" if $dbserver; 430 $command .= " -dep_id $dep_id" if $dep_id; 419 431 420 432 if ($mode eq "list_job") { … … 593 605 my $command = "$pstamptool -addjob -req_id $req_id -job_type $job_type" 594 606 . " -rownum $rownum -state stop -fault $fault"; 595 $command .= " -dbname $dbname" if $dbname;596 $command .= " -dbserver $dbserver" if $dbserver;597 607 598 608 if ($mode eq "list_job") { … … 717 727 } 718 728 729 sub queue_update_run 730 { 731 my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $need_magic, $label) = @_; 732 733 if (($state ne 'cleaned') and ($state ne 'update') and ($state ne 'goto_cleaned')) { 734 my_die("$stage $stage_id is in unexpected state $state", $PS_EXIT_PROG_ERROR); 735 } 736 737 my $dep_id; 738 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb"; 739 $command .= " -rlabel $label" if $label; 740 $command .= " -no_magic" if !$need_magic; 741 if (!$no_update) { 742 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 743 run(command => $command, verbose => $verbose); 744 unless ($success) { 745 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 746 } 747 my $output = join "", @$stdout_buf; 748 chomp $output; 749 $dep_id = $output; 750 my_die("pstamptool -getdependent returned invalid dep_id", $PS_EXIT_PROG_ERROR) if !$dep_id; 751 } else { 752 print STDERR "skipping $command\n"; 753 $dep_id = 42; 754 } 755 756 $$r_dep_id = $dep_id; 757 $r_fault = 0; 758 $r_jobState = 'blocked'; 759 } 760 719 761 sub my_die 720 762 { -
branches/eam_branches/20090820/pstamp/src/ppstampMakeStamp.c
r25766 r25870 157 157 return NULL; 158 158 } 159 if (copyWidth > width) { 160 copyWidth = width; 161 } 159 162 160 163 psImage *output = psImageAlloc(width, height, image->type.type); -
branches/eam_branches/20090820/pstamp/test/byskycell.txt
r25766 r25870 15 15 # subsequent lines define the rows in the table 16 16 17 ################################ OLD Format18 #19 # ROWNUM PROJECT JOB_TYPE OPTION_MASK REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT COORD_MASK CENTER_X CENTER_Y WIDTH HEIGHT REQFILT MJD_MIN MJD_MAX20 # warps from various epochs for one of the SN candidates. Specifiying the skycell speeds up processing21 # 1 gpc1 stamp 1 byskycell warp null MD07 skycell.044 2 214.509667604725 52.5181290488877 200 200 null 55009 5501122 23 24 25 17 # If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1 26 # If a later input row reuses a value an error occurs18 # If a later input row reuses a value an error is preported 27 19 28 20 # ID | ROI Specification | JOB Specification | Images of interest specification -
branches/eam_branches/20090820/pswarp/src/pswarpLoop.c
r25766 r25870 488 488 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 489 489 if (dump_file) { 490 pmConfigDump(config, dump_file); 490 if (!pmConfigDump(config, dump_file)) { 491 psError(PS_ERR_IO, false, "Unable to dump configuration"); 492 return false; 493 } 491 494 } 492 495 -
branches/eam_branches/20090820/tools/ipp_apply_burntool.pl
r25766 r25870 53 53 my $burntool = can_run('burntool') or (warn "Can't find burntool" and $missing_tools = 1); 54 54 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 55 my $nebXattr = can_run('neb-xattr') or (warn "Can't find neb-xattr" and $missing_tools = 1); 55 56 #my $fpack = can_run('fpack') or (warn "Can't find fpack" and $missing_tools = 1); 56 57 if ($missing_tools) { … … 190 191 } 191 192 193 $status = vsystem ("$neb-xattr --write $outTable user.copies:2"); 192 194 $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN); 193 195 if ($status) { -
branches/eam_branches/20090820/tools/warp_outputs.pl
r24236 r25870 16 16 'VARIANCE' => '.wt.fits', # Variance 17 17 'SOURCES' => '.cmf', # Sources 18 'PSF' => '.psf', # Point-Spread Function 18 19 }; 19 20
Note:
See TracChangeset
for help on using the changeset viewer.
