Changeset 37551
- Timestamp:
- Nov 3, 2014, 2:41:20 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 14 edited
-
ippScripts/scripts/addstar_run.pl (modified) (4 diffs)
-
ippTasks/addstar.pro (modified) (6 diffs)
-
ippToPsps/config/ippToPspsDbSchema.sql (modified) (1 diff)
-
ippToPsps/jython/Makefile.am (modified) (1 diff)
-
ippToPsps/jython/batch.py (modified) (1 diff)
-
ippToPsps/jython/detectionbatch.py (modified) (1 diff)
-
ippToPsps/jython/dvoforceddetections.py (added)
-
ippToPsps/jython/dvoforcedobjects.py (added)
-
ippToPsps/jython/forcedobjectbatch.py (modified) (1 diff)
-
ippToPsps/jython/forcedwarpbatch.py (modified) (1 diff)
-
ippToPsps/jython/gpc1db.py (modified) (2 diffs)
-
ippToPsps/jython/ipptopspsdb.py (modified) (1 diff)
-
ippTools/share/Makefile.am (modified) (5 diffs)
-
ippTools/share/addtool_find_diff_id.sql (added)
-
ippTools/share/addtool_find_diff_id_dvo.sql (added)
-
ippTools/share/addtool_find_ff_id.sql (added)
-
ippTools/share/addtool_find_ff_id_dvo.sql (added)
-
ippTools/share/addtool_find_pendingexp_diff.sql (added)
-
ippTools/share/addtool_find_pendingexp_ff.sql (added)
-
ippTools/share/addtool_find_processedexp_diff.sql (added)
-
ippTools/share/addtool_find_processedexp_ff.sql (added)
-
ippTools/share/addtool_queue_diff_id.sql (added)
-
ippTools/share/addtool_queue_ff_id.sql (added)
-
ippTools/share/addtool_revertprocessedexp_diff.sql (added)
-
ippTools/share/addtool_revertprocessedexp_ff.sql (added)
-
ippTools/src/addtool.c (modified) (13 diffs)
-
ippTools/src/addtoolConfig.c (modified) (4 diffs)
-
ippTools/src/pxadd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/addstar_run.pl
r34750 r37551 94 94 # Recipes to use based on reduction class 95 95 $reduction = 'DEFAULT' unless defined $reduction; 96 if ($stage =~/skycal/) { 97 $reduction = 'DEFAULT'; 98 } 96 if ($stage =~/diff/) { 97 $reduction = 'ADDSTAR'; 98 } 99 if ($stage =~/forcedwarp/) { 100 $reduction = 'ADDSTAR'; 101 } 102 99 103 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); 100 104 # XXX This is now not used: do we still need it? … … 132 136 print "using $fpaObjects for $stage\n"; 133 137 } 138 if ($stage =~/diff/) { 139 print "using $fpaObjects for $stage\n"; 140 } 141 if ($stage =~/forcedwarp/) { 142 print "using $fpaObjects for $stage\n"; 143 } 144 134 145 135 146 … … 177 188 } 178 189 179 if (($stage =~/stack/ || $stage =~ /skycal/ )) {190 if (($stage =~/stack/ || $stage =~ /skycal/ || $stage =~/diff/ || $stage=~/forcedwarp/)) { 180 191 $fpaObjects =~ s/smf$/cmf/; 181 192 $fpaObjectsAlt =~ s/smf$/cmf/; … … 305 316 $command .= " -quick-airmass"; 306 317 } #careful here - this matches staticsky and staticsky_multi 318 if ($stage =~ /diff/) { 319 $command .= " -accept-astrom"; 320 } 321 if ($stage =~ /forcedwarp/) { 322 $command .= " -accept-astrom -xrad"; 323 } 307 324 308 325 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script -
trunk/ippTasks/addstar.pro
r35305 r37551 52 52 active false 53 53 end 54 task addstar.revert.diff 55 active false 56 end 57 task addstar.revert.fullforce 58 active false 59 end 54 60 end 55 61 … … 65 71 end 66 72 task addstar.revert.skycal 73 active true 74 end 75 task addstar.revert.diff 76 active true 77 end 78 task addstar.revert.fullforce 67 79 active true 68 80 end … … 141 153 $addstar_revert_DB_SSM = 0 142 154 $addstar_revert_DB_SC = 0 155 $addstar_revert_DB_FF = 0 156 $addstar_revert_DB_DF = 0 143 157 144 158 #$LOADEXEC_ADD = 300 … … 275 289 sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID 276 290 end 291 if ("$STAGE" == "diff") 292 sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID 293 end 294 if ("$STAGE" == "fullforce") 295 sprintf outroot "%s.add.%s" $STAGEROOT $ADD_ID 296 end 277 297 278 298 … … 293 313 if ("$STAGE" == "skycal") 294 314 $run = $run --stage_id $STAGE_ID 315 end 316 if ("$STAGE" == "diff") 317 $run = $run --stage_id $STAGE_ID --stage_extra1 $STAGE_EXTRA1 318 end 319 if ("$STAGE" == "fullforce") 320 $run = $run --stage_id $STAGE_ID --stage_extra1 $STAGE_EXTRA1 295 321 end 296 322 … … 526 552 end 527 553 end 554 555 556 task addstar.revert.diff 557 host local 558 559 periods -poll 5.0 560 periods -exec 60.0 561 periods -timeout 1200 562 npending 1 563 active false 564 565 stdout NULL 566 stderr $LOGDIR/revert.log 567 568 task.exec 569 if ($LABEL:n == 0) break 570 $run = addtool -revertprocessedexp -stage diff 571 if ($DB:n == 0) 572 option DEFAULT 573 else 574 # save the DB name for the exit tasks 575 option $DB:$addstar_revert_DB_DF 576 $run = $run -dbname $DB:$addstar_revert_DB_DF 577 $addstar_revert_DB_DF ++ 578 if ($addstar_revert_DB_DF >= $DB:n) set addstar_revert_DB_DF = 0 579 end 580 add_poll_labels run 581 command $run 582 end 583 584 # success 585 task.exit 0 586 end 587 588 # locked list 589 task.exit default 590 showcommand failure 591 end 592 593 task.exit crash 594 showcommand crash 595 end 596 597 # operation times out? 598 task.exit timeout 599 showcommand timeout 600 end 601 end 602 603 604 task addstar.revert.fullforce 605 host local 606 607 periods -poll 5.0 608 periods -exec 60.0 609 periods -timeout 1200 610 npending 1 611 active false 612 613 stdout NULL 614 stderr $LOGDIR/revert.log 615 616 task.exec 617 if ($LABEL:n == 0) break 618 $run = addtool -revertprocessedexp -stage fullforce 619 if ($DB:n == 0) 620 option DEFAULT 621 else 622 # save the DB name for the exit tasks 623 option $DB:$addstar_revert_DB_FF 624 $run = $run -dbname $DB:$addstar_revert_DB_FF 625 $addstar_revert_DB_FF ++ 626 if ($addstar_revert_DB_FF >= $DB:n) set addstar_revert_DB_FF = 0 627 end 628 add_poll_labels run 629 command $run 630 end 631 632 # success 633 task.exit 0 634 end 635 636 # locked list 637 task.exit default 638 showcommand failure 639 end 640 641 task.exit crash 642 showcommand crash 643 end 644 645 # operation times out? 646 task.exit timeout 647 showcommand timeout 648 end 649 end -
trunk/ippToPsps/config/ippToPspsDbSchema.sql
r37246 r37551 189 189 SET character_set_client = @saved_cs_client; 190 190 -- 191 -- Table structure for table `forcedobject` 192 -- 193 194 DROP TABLE IF EXISTS `forcedobject`; 195 SET @saved_cs_client = @@character_set_client; 196 SET character_set_client = utf8; 197 CREATE TABLE `forcedobject` ( 198 `batch_id` bigint(20) unsigned NOT NULL, 199 `region` varchar(50) default NULL, 200 KEY `batch_id` (`batch_id`), 201 CONSTRAINT `diffobject_fk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`) 202 ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 203 SET character_set_client = @saved_cs_client; 204 205 -- 191 206 -- Table structure for table `diffobject` 192 207 -- -
trunk/ippToPsps/jython/Makefile.am
r37246 r37551 14 14 diffobjectbatch.py \ 15 15 dvodetections.py \ 16 dvoforceddetections.py \ 17 dvoforcedobjects.py \ 16 18 dvoobjects.py \ 17 19 dvo.py \ -
trunk/ippToPsps/jython/batch.py
r37246 r37551 579 579 # for OB, this imports object data from DVO 580 580 if not self.importIppTables(): 581 if self.batchType == "OB":581 if (self.batchType == "OB" or self.batchType =="DO" or self.batchType =="FO"): 582 582 self.logger.errorPair("skipping this batch", "no dvo tables for this region") 583 583 self.ippToPspsDb.updateProcessed(self.batchID, 1) -
trunk/ippToPsps/jython/detectionbatch.py
r37355 r37551 214 214 sqlLine.group("completMag", self.getKeyFloat(header, "%.8f", 'FLIMIT')) 215 215 sqlLine.group("astroScat", self.getKeyFloat(header, "%.8f", 'CERROR')) 216 sqlLine.group("photoScat", self.getKeyFloat(self.header, "%.8f", 'ZPT_ OBS'))216 sqlLine.group("photoScat", self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR')) 217 217 sqlLine.group("numAstroRef", self.getKeyValue(header, 'NASTRO')) 218 218 sqlLine.group("numPhotoRef", self.getKeyValue(header, 'NASTRO')) -
trunk/ippToPsps/jython/forcedobjectbatch.py
r36697 r37551 1 #!/usr/bin/env jython 2 3 import os.path 4 import sys 5 6 import stilts 7 from java.lang import * 8 from java.sql import * 9 10 from xml.etree.ElementTree import ElementTree, Element, tostring 11 12 from batch import Batch 13 from gpc1db import Gpc1Db 14 from ipptopspsdb import IppToPspsDb 15 from scratchdb import ScratchDb 16 from dvoforcedobjects import DvoForcedObjects # need one specific for cpy ? 17 from sqlUtility import sqlUtility 18 19 import logging.config 20 21 ''' 22 ForcedObjectBatch class 23 24 This class, a sub-class of Batch, processes individual DVO region file pairs (cpt, cpy, and cps files). The cpt file contains a list of all objects in that region, the cps file contains the magnitudes and so has a row per filter per object (so, generally, has rows = 5 x number of objects). The Photcode.dat table us used to figure out the number and order of filters as they appear in the cps file. 25 26 ''' 27 class ForcedMeanObjectBatch(Batch): 28 29 ''' 30 Constructor 31 ''' 32 def __init__(self, 33 logger, 34 config, 35 skychunk, 36 gpc1Db, 37 ippToPspsDb, 38 scratchDb, 39 dvoID, 40 batchID): 41 42 super(ForcedMeanObjectBatch, self).__init__( 43 logger, 44 config, 45 skychunk, 46 gpc1Db, 47 ippToPspsDb, 48 scratchDb, 49 dvoID, 50 batchID, 51 "FO", 52 None) 53 54 try: 55 self.dvoForcedObjects = DvoForcedObjects(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb) 56 except: 57 self.logger.errorPair("Unable to create instance of", "DvoForcedObjects") 58 raise 59 60 # create an output filename, which is {dvoINDEX}.FITS 61 self.outputFitsFile = "%08d.FITS" % self.id 62 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) 63 64 # dump stuff to log 65 self.logger.infoPair("DVO INDEX", "%d" % self.id) 66 67 ''' 68 Overriden from batch base-class. We import from DVO directly for forced mean objects 69 ''' 70 def importIppTables(self, columns="*", filter=""): 71 72 self.region = self.scratchDb.getRegionNameFromThisDvoIndex(self.id) 73 self.ippToPspsDb.insertForcedMeanObjectMeta(self.batchID, self.region) 74 self.dvoForcedObjects.nativeIngestRegion(self.region) 75 76 cptTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpt") 77 78 if not self.scratchDb.tableExists(cptTableName): 79 self.logger.infoPair("can't find in scratch db:","cpt table") 80 return False 81 82 cpyTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpy") 83 84 if not self.scratchDb.tableExists(cpyTableName): 85 self.logger.infoPair("can't find in scratch db:","cpy table") 86 return False 87 88 return True 89 90 ''' 91 Applies indexes to the PSPS tables 92 ''' 93 def alterPspsTables(self): 94 95 return True 96 97 ''' 98 Applies indexes to the IPP tables 99 ''' 100 def indexIppTables(self): 101 102 # since dvopsps is now used, no action is needed here 103 # self.logger.infoPair("Creating indexes on", "IPP tables") 104 105 return True 106 107 ''' 108 Inserts stuff for all mags 109 ''' 110 def updateForcedMeanObjectFromCps(self, cpsTable): 111 112 # list of all filters PSPS is interested in 113 # XXX EAM : 2014.07.24 : this list should probably be in a config file somewhere 114 interestedFilters = ['g', 'r', 'i', 'z', 'y'] 115 116 filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters) 117 118 # get a count of the available filters 119 filterCount = self.scratchDb.getCountOfFiltersFromPhotcodesTable() 120 121 self.logger.infoPair("Available filters in Photcodes", filters) 122 123 # the 'code' now defines the order in the cps file that the mags are listed for a given filter 124 self.logger.infoPair("Adding magnitudes from", "cps table") 125 for filter in filters: 126 127 filterID = self.scratchDb.getFilterID(filter[1]) 128 129 # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000) 130 # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags 131 # XXX EAM : 20140724 this manipulation is no longer needed : [grizy]Flags is now 4 byte (was 8 byte!) 132 133 # set the MeanObject fields based largely on dvopsps cps fields: 134 135 # XXX EAM 20140724 : filterCount is meant to match 136 # Nsecfilt, but is potentially not determined correctly. 137 # use a call to a dvo-native command which knows how to 138 # find Nsecfilt (or save in the db with dvopsps) 139 140 # the math below depends on filterCount = Nsecfilt and MeanObject.row being 1 counting but cps being 0 counting? 141 # cps.row has a count of MeanObject.row * Nsecfilt + Nfilter 142 # " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \ 143 144 sql = "UPDATE ForcedMeanObject JOIN \ 145 " + cpsTable + " AS cps ON (cps.row = (ForcedMeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \ 146 SET \ 147 ForcedMeanObject." + filter[1] + "nTotal = NWARP \ 148 ,ForcedMeanObject." + filter[1] + "nIncPSFMag = NUSED_WRP \ 149 ,ForcedMeanObject." + filter[1] + "nIncKronMag = NUSED_KRON_WRP \ 150 ,ForcedMeanObject." + filter[1] + "nIncApMag = NUSED_AP_WRP \ 151 ,ForcedMeanObject." + filter[1] + "PSFMag = MAG_PSF_WRP \ 152 ,ForcedMeanObject." + filter[1] + "PSFMagErr = MAG_PSF_WRP_ERR \ 153 ,ForcedMeanObject." + filter[1] + "PSFMagStd = MAG_PSF_WRP_STD \ 154 ,ForcedMeanObject." + filter[1] + "KronMag = MAG_KRON_WRP \ 155 ,ForcedMeanObject." + filter[1] + "KronMagErr = MAG_KRON_WRP_ERR \ 156 ,ForcedMeanObject." + filter[1] + "KronMagStd = MAG_KRON_WRP_STD \ 157 ,ForcedMeanObject." + filter[1] + "ApMag = MAG_AP_WRP \ 158 ,ForcedMeanObject." + filter[1] + "ApMagErr = MAG_AP_WRP_ERR \ 159 ,ForcedMeanObject." + filter[1] + "ApMagStd = MAG_AP_WRP_STD \ 160 ,ForcedMeanObject." + filter[1] + "Flags = FLAGS " 161 162 163 try: self.scratchDb.execute(sql) 164 except: 165 self.logger.errorPair("failed update MeanObject", sql) 166 raise 167 168 # now set to null all MeanMagErr values > 0.5 (cut set by Gene, 2012-04-12) 169 # XXX EAM 20140724 : keep this cut? 170 cut = 0.5 171 self.logger.infoPair("Setting to NULL all MeanMagErr value >", "%f" % cut) 172 for filter in filters: 173 174 sql = "UPDATE ForcedMeanObject \ 175 SET " + filter[1] + "PSFMagErr = null \ 176 WHERE " + filter[1] + "PSFMagErr > " + str(cut) 177 self.scratchDb.execute(sql) 178 179 self.logger.infoPair("Calculating nDetections from", "n[filters]") 180 for filter in filters: 181 # now do a sum of n[filters], but do not include the ones with -999 182 sql = "UPDATE ObjectThin " 183 sql += "SET nDetections = nDetections + n" + filter[1] 184 sql += " WHERE n" + filter[1] + " != -999" 185 self.scratchDb.execute(sql) 186 187 ''' 188 Inserts stuff for all mags from the cpy files 189 ''' 190 def updateForcedMeanObjectFromCpy(self, cpyTable): 191 192 # list of all filters PSPS is interested in 193 # XXX EAM : 2014.07.24 : this list should probably be in a config file somewhere 194 interestedFilters = ['g', 'r', 'i', 'z', 'y'] 195 196 filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters) 197 198 # get a count of the available filters 199 filterCount = self.scratchDb.getCountOfFiltersFromPhotcodesTable() 200 201 self.logger.infoPair("Available filters in Photcodes", filters) 202 203 # the 'code' now defines the order in the cps file that the mags are listed for a given filter 204 self.logger.infoPair("Adding magnitudes from", "cpy table") 205 for filter in filters: 206 207 filterID = self.scratchDb.getFilterID(filter[1]) 208 209 # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000) 210 # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags 211 # XXX EAM : 20140724 this manipulation is no longer needed : [grizy]Flags is now 4 byte (was 8 byte!) 212 213 # set the MeanObject fields based largely on dvopsps cps fields: 214 215 # XXX EAM 20140724 : filterCount is meant to match 216 # Nsecfilt, but is potentially not determined correctly. 217 # use a call to a dvo-native command which knows how to 218 # find Nsecfilt (or save in the db with dvopsps) 219 220 # the math below depends on filterCount = Nsecfilt and MeanObject.row being 1 counting but cps being 0 counting? 221 # cps.row has a count of MeanObject.row * Nsecfilt + Nfilter 222 # " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \ 223 224 sql = "UPDATE ForcedMeanObject JOIN \ 225 " + cpyTable + " AS cpy ON (cpy.row = (ForcedMeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \ 226 SET \ 227 ForcedMeanObject." + filter[1] + "nIncR5 = NMEAS \ 228 ,ForcedMeanObject." + filter[1] + "nIncR6 = NMEAS \ 229 ,ForcedMeanObject." + filter[1] + "FmeanflxR5 = FLUX_AP_R5 \ 230 ,ForcedMeanObject." + filter[1] + "FmeanflxR5Err = FLUX_ERR_AP_R5 \ 231 ,ForcedMeanObject." + filter[1] + "FmeanflxR5Std = FLUX_STD_AP_R5 \ 232 ,ForcedMeanObject." + filter[1] + "FmeanflxR5Fill = FLUX_FIL_AP_R5 \ 233 ,ForcedMeanObject." + filter[1] + "FmeanflxR6 = FLUX_AP_R6 \ 234 ,ForcedMeanObject." + filter[1] + "FmeanflxR6Err = FLUX_ERR_AP_R6 \ 235 ,ForcedMeanObject." + filter[1] + "FmeanflxR6Std = FLUX_STD_AP_R6 \ 236 ,ForcedMeanObject." + filter[1] + "FmeanflxR6Fill = FLUX_FIL_AP_R6 \ 237 ,ForcedMeanObject." + filter[1] + "LensObjSmearX11 = X11_SM_OBJ \ 238 ,ForcedMeanObject." + filter[1] + "LensObjSmearX12 = X12_SM_OBJ \ 239 ,ForcedMeanObject." + filter[1] + "LensObjSmearX22 = X22_SM_OBJ \ 240 ,ForcedMeanObject." + filter[1] + "LensObjSmearE1 = E1_SM_OBJ \ 241 ,ForcedMeanObject." + filter[1] + "LensObjSmearE2 = E2_SM_OBJ \ 242 ,ForcedMeanObject." + filter[1] + "LensObjShearX11 = X11_SH_OBJ \ 243 ,ForcedMeanObject." + filter[1] + "LensObjShearX12 = X12_SH_OBJ \ 244 ,ForcedMeanObject." + filter[1] + "LensObjShearX22 = X22_SH_OBJ \ 245 ,ForcedMeanObject." + filter[1] + "LensObjShearE1 = E1_SH_OBJ \ 246 ,ForcedMeanObject." + filter[1] + "LensObjShearE2 = E2_SH_OBJ \ 247 ,ForcedMeanObject." + filter[1] + "LensPSFSmearX11 = X11_SM_PSF \ 248 ,ForcedMeanObject." + filter[1] + "LensPSFSmearX12 = X12_SM_PSF \ 249 ,ForcedMeanObject." + filter[1] + "LensPSFSmearX22 = X22_SM_PSF \ 250 ,ForcedMeanObject." + filter[1] + "LensPSFSmearE1 = E1_SM_PSF \ 251 ,ForcedMeanObject." + filter[1] + "LensPSFSmearE2 = E2_SM_PSF \ 252 ,ForcedMeanObject." + filter[1] + "LensPSFShearX11 = X11_SH_PSF \ 253 ,ForcedMeanObject." + filter[1] + "LensPSFShearX12 = X12_SH_PSF \ 254 ,ForcedMeanObject." + filter[1] + "LensPSFShearX22 = X22_SH_PSF \ 255 ,ForcedMeanObject." + filter[1] + "LensPSFShearE1 = E1_SH_PSF \ 256 ,ForcedMeanObject." + filter[1] + "LensPSFShearE2 = E2_SH_PSF \ 257 ,ForcedMeanObject." + filter[1] + "Gamma = GAMMA \ 258 ,ForcedMeanObject." + filter[1] + "E1 = E1 \ 259 ,ForcedMeanObject." + filter[1] + "E2 = E2 " 260 261 262 try: self.scratchDb.execute(sql) 263 except: 264 self.logger.errorPair("failed update on ForcedMeanObject using cpy table", sql) 265 raise 266 267 268 ''' 269 Populates the ForcedMeanObject table 270 ''' 271 def populateForcedMeanObjectTable(self): 272 273 cptTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpt") 274 cpsTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cps") 275 cpyTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpy") 276 277 278 self.logger.info("Populating ForcedMeanObject") 279 self.logger.info("Inserting objects from cpt file") 280 281 # note "dec" is a reserved word in MySQL 282 # XXX EAM 20140724 : do not use INGORE unless we discover unavoidable problems... 283 # INSERT IGNORE INTO ObjectThin 284 285 sqlLine = sqlUtility("INSERT INTO ForcedMeanObject (") 286 287 sqlLine.group("objID", "EXT_ID") 288 sqlLine.group("ippObjID", "OBJ_ID + (CAT_ID << 32)") # NOTE: shift by 32 bits exactly 289 sqlLine.group("batchID", "'" + str(self.batchID) + "'") 290 sqlLine.group("nDetections", "'0'") 291 sql = sqlLine.makeRaw(") SELECT ", " FROM " + cptTableName) 292 293 try: 294 self.scratchDb.execute(sql) 295 except: 296 self.logger.errorPair("Couldn't populate Object table from cpt", sql) 297 return False 298 299 # add row count columns so we can perform joins to get colors 300 self.logger.infoPair("Adding 'row' columns to", "Object and cps tables") 301 self.scratchDb.addRowCountColumn("ForcedMeanObject", "row") 302 self.scratchDb.addRowCountColumn(cpsTableName, "row") 303 304 305 self.logger.infoPair("update ForcedMeanObject from ","cps table") 306 307 self.updateForcedMeanObjectFromCps(cpsTableName) 308 309 self.logger.infoPair("update ForcedMeanObject from ","cpy table") 310 311 self.updateForcedMeanObjectFromCpy(cpyTableName) 312 313 314 self.logger.infoPair("Dropping row column from", "ForcedMeanObject table") 315 self.scratchDb.dropColumn("ForcedMeanObject", "row") 316 317 ##self.logger.infoPair("Purging from scratch Db", self.region + " region") 318 319 ##Don't do this till after MeanObject 320 ##self.dvoForcedObjects.purgeRegion(self.region) 321 322 self.setMinMaxObjID(["ForcedMeanObject"]) 323 324 return True 325 326 327 ''' 328 Does the processing, i.e. pulling stuff from IPP tables into PSPS tables 329 ''' 330 def populatePspsTables(self): 331 332 if not self.populateForcedMeanObjectTable(): return False 333 334 # now remove the objID duplicates. We could not do this before as cpt/cps tables relate by row number 335 self.logger.infoPair("Forcing uniqueness on", "objID in ForcedMeanObject table") 336 rowCountBefore = self.scratchDb.getRowCount("ForcedMeanObject") 337 338 # XXX EAM : note that in mysql versions later than 5.1, this fails 339 # unless the following is called first: 340 # set session old_alter_table=1 341 # follow the command with 342 # set session old_alter_table=0 343 # OF COURSE, this fails for mysql version < 5.5... 344 if self.scratchDb.version > 5.1: 345 self.scratchDb.execute("set session old_alter_table=1") 346 347 self.scratchDb.execute("ALTER IGNORE TABLE ForcedMeanObject ADD UNIQUE INDEX(objID)") 348 if self.scratchDb.version > 5.1: 349 self.scratchDb.execute("set session old_alter_table=0") 350 351 rowCountAfter = self.scratchDb.getRowCount("ForcedMeanObject") 352 self.logger.infoPair("Number of duplicated objIDs removed", "%d out of %d" % ((rowCountBefore - rowCountAfter), rowCountBefore)) 353 354 self.dvoForcedObjects.purgeRegion(self.region) 355 356 #this is abuse of something but this is how I get the object batches to crash to further investigate them 357 358 # rowCountAfter = self.scratchDb.getRowCount("Object") 359 return True 360 # return False -
trunk/ippToPsps/jython/forcedwarpbatch.py
r36697 r37551 1 #!/usr/bin/env jython 2 3 import os.path 4 import sys 5 import glob 6 import time 7 import stilts 8 9 from java.lang import * 10 from java.sql import * 11 12 from java.lang import Math 13 from org.apache.commons.math.special import Erf 14 15 from xml.etree.ElementTree import ElementTree, Element, tostring 16 17 from batch import Batch 18 from gpc1db import Gpc1Db 19 from ipptopspsdb import IppToPspsDb 20 from scratchdb import ScratchDb 21 from sqlUtility import sqlUtility 22 23 import logging.config 24 25 26 ''' 27 ForcedWarpBatch class 28 29 This class, a sub-class of Batch, processes single exposures in the form of IPP smf files 30 31 ''' 32 class ForcedWarpBatch(Batch): 33 34 ''' 35 Constructor 36 ''' 37 def __init__(self, 38 logger, 39 config, 40 skychunk, 41 gpc1Db, 42 ippToPspsDb, 43 scratchDb, 44 forcedWarpID, 45 batchID): 46 47 super(ForcedWarpBatch, self).__init__( 48 logger, 49 config, 50 skychunk, 51 gpc1Db, 52 ippToPspsDb, 53 scratchDb, 54 forcedWarpID, 55 batchID, 56 "P2", 57 gpc1Db.getForcedWarpStageSmf(forcedWarpID) 58 59 # get camera meta data 60 meta = self.gpc1Db.getForcedWarpStageMeta(self.id) 61 if not meta: 62 self.logger.errorPair("Could not get", "forced warp metadata") 63 raise 64 65 self.expID = meta[0]; 66 self.expName = meta[1]; 67 self.distGroup = meta[2]; 68 self.analysisVer = meta[3]; 69 self.bias = meta[4]; 70 self.biasScat = meta[5]; 71 72 if not self.analysisVer: self.analysisVer = -999 73 74 # create an output filename, which is {expID}.FITS 75 self.outputFitsFile = "%08d.FITS" % self.expID 76 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) 77 self.dropTableVerbose("ForcedWarpMeasurement") 78 self.dropTableVerbose("ForcedWarpExtended") 79 self.dropTableVerbose("ForcedWarpMeta") 80 self.dropTableVerbose("ForcedWarpToImage") 81 if not self.config.retry: 82 self.scratchDb.dropTable("ForcedWarpMeasurement") 83 self.scratchDb.dropTable("ForcedWarpExtended") 84 self.scratchDb.dropTable("ForcedWarpMeta") 85 self.scratchDb.dropTable("ForcedWarpToImage") 86 self.historyModNum = "0" 87 88 # get a few primary header values. if in test mode, then use defaults 89 if self.safeDictionaryAccessWithDefault(self.header, 'MJD-OBS', "1") == "NULL": 90 self.logger.errorPair("Could not get", "MJD-OBS") 91 raise 92 93 94 if self.safeDictionaryAccessWithDefault(self.header, 'EXPTIME', "1") == "NULL": 95 self.logger.errorPair("Could not get", "EXPTIME") 96 raise 97 98 if self.safeDictionaryAccessWithDefault(self.header, 'FILTERID', "g.0000") == "NULL": 99 self.logger.errorPair("Could not get", "FILTERID") 100 raise 101 102 # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2 103 self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0) 104 105 # set up some defauts 106 self.calibModNum = 0 107 self.totalNumPhotoRef = 0 108 109 110 self.filter = self.header['FILTERID'][0:1] 111 self.filterID = self.scratchDb.getFilterID(self.filter) 112 113 # insert what we know about this stack batch into the stack table 114 self.ippToPspsDb.insertDetectionMeta(self.batchID, self.expID, self.filter) 115 116 # dump stuff to log 117 self.logger.infoPair("Cam ID", "%d" % self.id) 118 self.logger.infoPair("Exp ID", "%d" % self.expID) 119 self.logger.infoPair("Exp name", "%s" % self.expName) 120 self.logger.infoPair("Distribution group", "%s" % self.distGroup) 121 122 123 124 125 ''' 126 Populates the FrameMeta table, mainly from dictionary values found in IPP FITS header 127 ''' 128 def populateForcedWarpMeta(self): 129 self.logger.infoPair("Processing table", "ForcedWarpMeta") 130 131 photoCalID = str(self.scratchDb.getPhotoCalID(forcedWarpID)) 132 133 134 sqlLine = sqlUtility("INSERT INTO ForcedWarpMeta (") 135 #batchID (below) 136 #surveyID (below) 137 #filterdID (below) 138 sqlLine.group("skyCellID", str(self.skycellID)) 139 sqlLine.group("photoCalID", photoCalID) 140 sqlLine.group("magSat", self.getKeyFloat(header, "%.8f", 'FSATUR')) 141 sqlLine.group("analVer", self.analysisVer); 142 sqlLine.group("expTime", self.getKeyFloat(self.header, "%.8f", 'EXPREQ')); 143 sqlLine.group("completMag", self.getKeyFloat(header, "%.8f", 'FLIMIT')) 144 sqlLine.group("astroScat", self.getKeyFloat(header, "%.8f", 'CERROR')) 145 sqlLine.group("photoScat", self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR')); 146 sqlLine.group("nAstroRef", self.getKeyValue(header, 'NASTRO')) 147 sqlLine.group("nPhotoRef", self.getKeyValue(header, 'NASTRO')) 148 sqlLine.group("psfModelID", self.getKeyValue(header, 'PSFMODEL')) 149 sqlLine.group("psfFwhm_mean", self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')) 150 sqlLine.group("psfFwhm_max", self.getKeyFloat(header, "%.8f", 'FW_MJ_UQ')) 151 sqlLine.group("photoZero", self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS')) 152 #photoColor -- how do I set this? it's also not set in stack meta 153 sqlLine.group("ctype1", self.getKeyValue(self.header, 'CTYPE1')); 154 sqlLine.group("ctype2", self.getKeyValue(self.header, 'CTYPE2')); 155 sqlLine.group("crval1", self.getKeyFloat(self.header, "%.8f", 'CRVAL1')); 156 sqlLine.group("crval2", self.getKeyFloat(self.header, "%.8f", 'CRVAL2')); 157 sqlLine.group("crpix1", self.getKeyFloat(self.header, "%.8f", 'CRPIX1')); 158 sqlLine.group("crpix2", self.getKeyFloat(self.header, "%.8f", 'CRPIX2')); 159 sqlLine.group("cdelt1", self.getKeyFloat(self.header, "%.8e", 'CDELT1')); 160 sqlLine.group("cdelt2", self.getKeyFloat(self.header, "%.8e", 'CDELT2')); 161 sqlLine.group("pc001001", self.getKeyFloat(self.header, "%.8e", 'PC001001')); 162 sqlLine.group("pc001002", self.getKeyFloat(self.header, "%.8e", 'PC001002')); 163 sqlLine.group("pc002001", self.getKeyFloat(self.header, "%.8e", 'PC002001')); 164 sqlLine.group("pc002002", self.getKeyFloat(self.header, "%.8e", 'PC002002')); 165 166 167 sql = sqlLine.make(") VALUES ( ", ")") 168 169 try: self.scratchDb.execute(sql) 170 except: 171 self.logger.errorPair('failed sql: ', sql) 172 raise 173 174 self.scratchDb.updateAllRows("ForcedWarpMeta", "batchID", str(self.batchID)) 175 self.scratchDb.updateAllRows("ForcedWarpMeta", "surveyID", str(self.surveyID)) 176 self.scratchDb.updateFilterID("ForcedWarpMeta", self.filter) 177 self.scratchDb.updateAllRows("ForcedWarpMeta", "calibModNum", str(self.calibModNum)) 178 self.scratchDb.updateAllRows("ForcedWarpMeta", "dataRelease", str(self.skychunk.dataRelease)) 179 self.tablesToExport.append("ForcedWarpMeta") 180 181 ''' 182 Populates the ForcedWarpToImage table 183 ''' 184 def populateForcedWarpToImage(self): 185 186 self.logger.infoPair("Procesing table", "ForcedWarpToImage") 187 188 for filter in self.filters: 189 190 forcedwarpID = self.forcedwarpID 191 if forcedwarpID > 0: 192 193 imageIDs = self.gpc1Db.getImageIDsForThisForcedWarpID(forcedwarpID) 194 195 for imageID in imageIDs: 196 197 sql = "INSERT INTO ForcedWarpToImage (forcedwarpID, imageID) \ 198 VALUES (\ 199 " + str(forcedwarpID) + ", " + imageID + ")" 200 self.scratchDb.execute(sql) 201 202 # now update StackMeta with correct number of inputs 203 204 self.tablesToExport.append("ForcedWarpToImage") 205 206 207 208 209 210 ''' 211 Populates the ForcedWarpMeasurement table 212 ''' 213 def populateForcedWarpMeasurementTable(self, results): 214 215 pspsTableName = "ForcedWarpMeasurement" 216 ippTableName = "ForcedWarpMeasurement_psf" 217 218 219 self.logger.infoPair("Procesing table", "ForcedWarpMeasurement") 220 221 # insert the per-object data (IDs, random stack ID, dataRelease, etc) 222 self.selectDvoObjIDs() 223 224 self.generateRandomIDs() 225 226 # add indexes ForcedWarpMeasurement 227 self.scratchDb.createIndex("ForcedWarpMeasurement", "objID") 228 229 230 231 232 233 234 235 236 237 self.tablesToExport.append("ForcedWarpMeasurement") 238 239 240 ''' 241 Populates the ForcedWarpExtended table 242 ''' 243 def populateForcedWarpExtendedTable(self, results): 244 245 pspsTableName = "ForcedWarpExtended" 246 ippTableName = "ForcedWarpExtended_psf" 247 248 249 self.tablesToExport.append("ForcedWarpExtended") 250 251 252 ''' 253 Does the processing, i.e. pulling stuff from IPP tables into PSPS tables 254 ''' 255 def populatePspsTables(self): 256 self.logger.infoPair("starting","populatePspsTables"); 257 self.skipBatch = False 258 # each of the "populate*" methods below add their tables to the list: 259 self.tablesToExport=[] 260 261 #this should be done 262 self.populateForcedWarpMeta() 263 264 self.populateForcedWarpMeasurement() 265 self.populateForcedWarpExtended() 266 self.populateForcedWarpToImage() 267 268 self.setMinMaxObjID(["ForcedWarpMeasurement"]) 269 270 self.logger.infoPair("finishing","populatePspsTables"); 271 return True 272 273 274 275 ''' 276 This function reads the cmf/smf file and loads it into the database as its own table 277 ''' 278 def importIppTables(self, columns="*", tableRE=""): 279 280 if self.config.retry: return True 281 self.logger.infoPair("Importing FW tables with table match expression: ", tableRE) 282 fileName = self.fits.getPath() 283 284 self.logger.infoPair("using filename:",fileName) 285 286 try: 287 tables = stilts.treads(fileName) 288 except: 289 self.logger.errorPair("STILTS could not import from", fileName) 290 return False 291 for table in tables: 292 293 match = re.match(tableRE, table.name) 294 if not match: continue 295 self.logger.infoPair("Reading IPP table", table.name) 296 table = stilts.tpipe(table, cmd='addcol table_index $0') 297 table = stilts.tpipe(table, cmd='explodeall') 298 299 # drop any previous tables before import 300 self.scratchDb.dropTable(table.name) 301 302 # IPP FITS files are littered with infinities, so remove these 303 self.logger.info("Removing Infinity values from all columns") 304 table = stilts.tpipe(table, cmd='keepcols "' + columns + '"') 305 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 306 table = stilts.tpipe(table, cmd='replaceval Infinity null *') 307 308 try: 309 table.write(self.scratchDb.url + '#' + table.name) 310 count = count + 1 311 except: 312 self.logger.exception("Problem writing table '" + table.name + "' to the database") 313 314 self.logger.infoPair("Done. Imported", "%d tables" % count) 315 self.indexIppTables() 316 317 return True 318 319 320 321 322 323 324 325 326 327 def generateRandomIDs(self): 328 sql = "UPDATE ForcedWarpMeasurement set randomWarpID = FLOOR(RAND()*9223372036854775807)"; 329 try: self.scratchDb.execute(sql) 330 except: 331 self.logger.errorPair('failed sql',sql) 332 return 333 334 335 336 337 338 339 340 341 342 def exportPspsTablesToFits(self, regex="(.*)"): 343 return super(DetectionBatch, self).exportPspsTablesToFits("(ForcedWarp.*)") -
trunk/ippToPsps/jython/gpc1db.py
r37246 r37551 116 116 117 117 stage = "forcedwarp" 118 sql = "SELECT differentStuff from Stufftable" 118 sql = "SELECT DISTINCT sky_id, radeg, decdeg FROM fullForceInput \ 119 JOIN addRun ON(fullForceInput.ff_id = addRun.stage_id, fullForceInput.warp_id = addRun.stage_extra1) \ 120 JOIN minidvodbRun USING(minidvodb_name) \ 121 JOIN minidvodbProcessed USING(minidvodb_id) \ 122 JOIN mergedvodbRun USING(minidvodb_id) \ 123 JOIN mergedvodbProcessed USING (merge_id) \ 124 JOIN fullForceRun USING(ff_id) \ 125 JOIN skycalRun using (skycal_id) 126 JOIN stackRun USING(stack_id) \ 127 JOIN stackSumSkyfile using (stack_id) \ 128 JOIN skycell USING(skycell_id) \ 129 WHERE mergedvodbRun.mergedvodb = '" + dvoDb + "' \ 130 AND minidvodbRun.state = 'merged' \ 131 AND minidvodbProcessed.fault = 0 \ 132 AND mergedvodbRun.state = 'full' \ 133 AND mergedvodbProcessed.fault = 0 \ 134 AND addRun.stage = '" + stage + "' \ 135 AND addRun.state = 'full' \ 136 AND decdeg BETWEEN " + str(minDec) + " AND " + str(maxDec) + " \ 137 AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \ 138 AND mjd_obs >= (to_days('" + tstart + "')-678941) \ 139 AND mjd_obs <= (to_days('" + tend + "') - 678941) " 119 140 120 141 try: … … 165 186 166 187 return imageIDs 188 189 190 191 192 167 193 168 194 ''' -
trunk/ippToPsps/jython/ipptopspsdb.py
r37246 r37551 756 756 757 757 self.execute(sql) 758 759 ''' 760 Inserts some forced detection metadata for this batch ID 761 ''' 762 def insertForcedWarpMeta(self, batchID, expID, filter): 763 764 sql = "INSERT INTO forcedwarp ( \ 765 batch_id \ 766 ,exp_id \ 767 ,filter \ 768 ) VALUES ( \ 769 " + str(batchID) + " \ 770 ," + str(expID) + " \ 771 ,'" + filter + "' \ 772 )" 773 774 self.execute(sql) 775 776 777 778 ''' 779 Inserts some forcedobject metadata for this batch ID 780 ''' 781 def insertForcedObjectMeta(self, batchID, region): 782 783 sql = "INSERT INTO forcedobject ( \ 784 batch_id \ 785 ,region \ 786 ) VALUES ( \ 787 " + str(batchID) + " \ 788 ,'" + region + "' \ 789 )" 790 791 self.execute(sql) 792 793 794 795 796 ''' 797 Inserts some diff metadata for this batch ID 798 ''' 799 def insertDiffMeta(self, batchID, filter, diffType): 800 801 sql = "INSERT INTO stack ( \ 802 batch_id \ 803 ,filter \ 804 ,diff_type \ 805 ) VALUES ( \ 806 " + str(batchID) + " \ 807 ,'" + filter + "' \ 808 ,'" + diffType + "')" 809 810 self.execute(sql) 811 812 813 814 815 ''' 816 Inserts some diffobject metadata for this batch ID 817 ''' 818 def insertDiffObjectMeta(self, batchID, region): 819 820 sql = "INSERT INTO diffobject ( \ 821 batch_id \ 822 ,region \ 823 ) VALUES ( \ 824 " + str(batchID) + " \ 825 ,'" + region + "' \ 826 )" 827 828 self.execute(sql) 829 830 831 832 833 834 758 835 ''' 759 836 Resets a batch ready for re-loading to the datastore -
trunk/ippTools/share/Makefile.am
r37384 r37551 8 8 addtool_find_cam_id_dvo.sql \ 9 9 addtool_find_cam_id.sql \ 10 addtool_find_diff_id.sql \ 11 addtool_find_diff_id_dvo.sql \ 12 addtool_find_ff_id.sql \ 13 addtool_find_ff_id_dvo.sql \ 10 14 addtool_find_skycal_id_dvo.sql \ 11 15 addtool_find_skycal_id.sql \ … … 16 20 addtool_find_pendingexp.sql \ 17 21 addtool_find_pendingexp_cam.sql \ 22 addtool_find_pendingexp_diff.sql \ 23 addtool_find_pendingexp_ff.sql \ 18 24 addtool_find_pendingexp_skycal.sql \ 19 25 addtool_find_pendingexp_stack.sql \ … … 21 27 addtool_find_pendingmergeprocess.sql \ 22 28 addtool_find_processedexp_cam.sql \ 29 addtool_find_processedexp_diff.sql \ 30 addtool_find_processedexp_ff.sql \ 23 31 addtool_find_processedexp_skycal.sql \ 24 32 addtool_find_processedexp_stack.sql \ … … 29 37 addtool_pendingcleanuprun.sql \ 30 38 addtool_queue_cam_id.sql \ 39 addtool_queue_diff_id.sql \ 40 addtool_queue_ff_id.sql \ 31 41 addtool_queue_stack_id.sql \ 32 42 addtool_queue_sky_id_multi.sql \ … … 35 45 addtool_revertminidvodbprocessed.sql \ 36 46 addtool_revertprocessedexp_cam.sql \ 47 addtool_revertprocessedexp_diff.sql \ 48 addtool_revertprocessedexp_ff.sql \ 37 49 addtool_revertprocessedexp_skycal.sql \ 38 50 addtool_revertprocessedexp_stack.sql \ -
trunk/ippTools/src/addtool.c
r35304 r37551 122 122 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 123 123 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 124 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 125 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 126 124 127 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 125 128 if (strcmp(stage, "cam")== 0) { … … 146 149 PXOPT_COPY_STR(config->args, where, "-reduction", "skycalRun.reduction", "=="); 147 150 } 148 151 if (strcmp(stage, "diff")==0) { 152 pxAddLabelSearchArgs (config, where, "-label", "diffRun.label", "=="); //define using skycalRun label 153 pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "=="); 154 PXOPT_COPY_STR(config->args, where, "-reduction", "diffRun.reduction", "=="); 155 } 156 if (strcmp(stage, "fullforce")==0) { 157 pxAddLabelSearchArgs (config, where, "-label", "fullForceRun.label", "=="); //define using skycalRun label 158 pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "=="); 159 PXOPT_COPY_STR(config->args, where, "-reduction", "fullForceRun.reduction", "=="); 160 } 161 162 163 149 164 if (!psListLength(where->list)) { 150 165 psFree(where); … … 258 273 } 259 274 260 275 if (strcmp(stage,"diff") == 0) { 276 if (dvodb ) { 277 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_diff_id_dvo.sql\n%s\n", dvodb,stage); 278 // find the skycal_id of all the exposures that we want to queue up. 279 bare_query = pxDataGet("addtool_find_diff_id_dvo.sql"); 280 // user supplied dvodb 281 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 282 } else { 283 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_diff_id.sql\n%s\n",stage); 284 // find the skycal_id of all the exposures that we want to queue up. 285 bare_query = pxDataGet("addtool_find_diff_id.sql"); 286 // inherit dvodb from skycalRun, avoid matching NULL 287 psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)"); 288 // this is silly, there is no dvodb in skycalRun...? 289 } 290 } 291 292 if (strcmp(stage,"fullforce") == 0) { 293 if (dvodb ) { 294 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ff_id_dvo.sql\n%s\n", dvodb,stage); 295 // find the skycal_id of all the exposures that we want to queue up. 296 bare_query = pxDataGet("addtool_find_ff_id_dvo.sql"); 297 // user supplied dvodb 298 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 299 } else { 300 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ff_id.sql\n%s\n",stage); 301 // find the skycal_id of all the exposures that we want to queue up. 302 bare_query = pxDataGet("addtool_find_ff_id.sql"); 303 // inherit dvodb from skycalRun, avoid matching NULL 304 psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)"); 305 // this is silly, there is no dvodb in skycalRun...? 306 } 307 } 261 308 262 309 … … 324 371 psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 325 372 } 373 //needs to be checked HAF xxx 374 if (strcmp(stage,"diff") == 0) { 375 psStringAppend(&query, " GROUP BY diff_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 376 } 377 //needs to be checked HAF xxx 378 if (strcmp(stage,"fullforce") == 0) { 379 psStringAppend(&query, " GROUP BY ff_id, skycal_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 380 } 381 382 383 326 384 327 385 psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query); … … 476 534 } 477 535 536 if (strcmp(stage,"diff") == 0) { 537 for (long i = 0; i < psArrayLength(output); i++) { 538 psMetadata *md = output->data[i]; 539 540 diffRunRow *row = diffRunObjectFromMetadata(md); 541 542 if (!row) { 543 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 544 psFree(output); 545 return false; 546 } 547 548 if (!dvodb) { // there's no skycalRun.dvodb 549 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id); 550 psFree(output); 551 return false; 552 } 553 if (!workdir && !row->workdir) { 554 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id); 555 psFree(output); 556 return false; 557 } 558 559 psFree(row); 560 } 561 } 562 563 if (strcmp(stage,"fullforce") == 0) { 564 for (long i = 0; i < psArrayLength(output); i++) { 565 psMetadata *md = output->data[i]; 566 567 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 568 569 if (!row) { 570 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 571 psFree(output); 572 return false; 573 } 574 575 if (!dvodb) { // there's no skycalRun.dvodb 576 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id); 577 psFree(output); 578 return false; 579 } 580 if (!workdir && !row->workdir) { 581 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id); 582 psFree(output); 583 return false; 584 } 585 586 psFree(row); 587 } 588 } 478 589 479 590 … … 672 783 } 673 784 785 if (strcmp(stage,"diff") == 0) { 786 for (long i = 0; i < psArrayLength(output); i++) { 787 psMetadata *md = output->data[i]; 788 psS64 stage_id =0; 789 790 diffRunRow *row = diffRunObjectFromMetadata(md); 791 stage_id = row->diff_id; 792 793 if (!row) { 794 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 795 psFree(output); 796 return false; 797 } 798 799 // queue the exp 800 if (!pxaddQueueByCamID(config, 801 stage, 802 stage_id, 803 0, 804 workdir ? workdir : row->workdir, 805 reduction ? reduction : row->reduction, 806 label ? label : row->label, 807 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 808 dvodb ? dvodb : NULL, 809 note ? note : NULL, 810 image_only, 811 minidvodb, 812 minidvodb_group, 813 minidvodb_name 814 )) { 815 if (!psDBRollback(config->dbh)) { 816 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 817 } 818 psError(PS_ERR_UNKNOWN, false, 819 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 820 psFree(row); 821 psFree(output); 822 return false; 823 } 824 psFree(row); 825 } 826 } 827 828 if (strcmp(stage,"fullforce") == 0) { 829 for (long i = 0; i < psArrayLength(output); i++) { 830 psMetadata *md = output->data[i]; 831 psS64 stage_id =0; 832 833 fullForceRunRow *row = fullForceRunObjectFromMetadata(md); 834 stage_id = row->ff_id; 835 836 if (!row) { 837 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 838 psFree(output); 839 return false; 840 } 841 842 // queue the exp 843 if (!pxaddQueueByCamID(config, 844 stage, 845 stage_id, 846 0, 847 workdir ? workdir : row->workdir, 848 reduction ? reduction : row->reduction, 849 label ? label : row->label, 850 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 851 dvodb ? dvodb : NULL, 852 note ? note : NULL, 853 image_only, 854 minidvodb, 855 minidvodb_group, 856 minidvodb_name 857 )) { 858 if (!psDBRollback(config->dbh)) { 859 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 860 } 861 psError(PS_ERR_UNKNOWN, false, 862 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 863 psFree(row); 864 psFree(output); 865 return false; 866 } 867 psFree(row); 868 } 869 } 870 871 872 674 873 675 874 … … 695 894 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 696 895 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 896 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 897 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 898 697 899 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 698 900 pxcamGetSearchArgs (config, where); // most search arguments based on camera … … 709 911 psString query = NULL; 710 912 if (strcmp(stage, "cam")==0) { 711 query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_idJOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");913 query = psStringCopy("UPDATE addRun JOIN camRun on (cam_id = stage_id and stage = 'cam') JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 712 914 } 713 915 if (strcmp(stage, "stack")==0) { 714 query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");916 query = psStringCopy("UPDATE addRun JOIN stackRun on (stack_id = stage_id and stage = 'stack')"); 715 917 } 716 918 if (strcmp(stage, "staticsky")==0) { 717 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");919 query = psStringCopy("UPDATE addRun JOIN staticskyRun on (sky_id = stage_id and stage = 'staticsky')"); 718 920 } 719 921 if (strcmp(stage, "skycal")==0) { 720 query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id"); 922 query = psStringCopy("UPDATE addRun JOIN skycalRun on (skycal_id = stage_id and stage = 'skycal')"); 923 } 924 if (strcmp(stage, "diff")==0) { 925 query = psStringCopy("UPDATE addRun JOIN diffInputSkyfile on (diff_id = stage_id and diff_skyfile_id = stage_extra1 and stage = 'diff') JOIN diffSkyfile on (diff_id, skycell_id) JOIN diffRun using (diff_id)"); 926 } 927 if (strcmp(stage, "fullforce")==0) { 928 query = psStringCopy("UPDATE addRun JOIN fullForceResult on (ff_id = stage_id and warp_id = stage_extra1 and stage = 'fullforce') JOIN fullForceRun on (ff_id)"); 721 929 } 722 930 … … 743 951 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 744 952 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 953 PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "=="); 954 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "=="); 745 955 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 746 956 pxcamGetSearchArgs (config, where); … … 764 974 query = pxDataGet("addtool_find_pendingexp_skycal.sql"); 765 975 } 976 if (strcmp(stage, "diff")==0) { 977 query = pxDataGet("addtool_find_pendingexp_diff.sql"); 978 } 979 if (strcmp(stage, "fullforce")==0) { 980 query = pxDataGet("addtool_find_pendingexp_ff.sql"); 981 } 766 982 767 983 … … 790 1006 psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1"); 791 1007 } 1008 if (strcmp(stage, "diff") == 0) { 1009 //this group by is needed to join against all the warps (to get camera) 1010 psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1"); 1011 } 1012 if (strcmp(stage, "fullforce") == 0) { 1013 //this group by is needed to join against all the warps (to get camera) 1014 psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1"); 1015 } 1016 1017 1018 792 1019 // treat limit == 0 as "no limit" 793 1020 if (limit) { … … 994 1221 } else if (strcmp (stage,"skycal") == 0) { 995 1222 query = pxDataGet("addtool_find_processedexp_skycal.sql"); 1223 } else if (strcmp (stage,"diff") == 0) { 1224 query = pxDataGet("addtool_find_processedexp_diff.sql"); 1225 } else if (strcmp (stage,"fullforce") == 0) { 1226 query = pxDataGet("addtool_find_processedexp_ff.sql"); 1227 996 1228 } else { 997 1229 psFree(where); … … 1112 1344 if (strcmp(stage, "skycal") == 0) { 1113 1345 query = pxDataGet("addtool_revertprocessedexp_skycal.sql"); 1346 } 1347 if (strcmp(stage, "diff") == 0) { 1348 query = pxDataGet("addtool_revertprocessedexp_diff.sql"); 1349 } 1350 if (strcmp(stage, "fullforce") == 0) { 1351 query = pxDataGet("addtool_revertprocessedexp_ff.sql"); 1114 1352 } 1115 1353 -
trunk/ippTools/src/addtoolConfig.c
r35228 r37551 55 55 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-skycal_id", 0, "search by skycal_id", 0); 56 56 pxcamSetSearchArgs(definebyqueryArgs); 57 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-diff_id", 0, "search by diff_id", 0); 58 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-ff_id", 0, "search by ff_id", 0); 57 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL); 58 60 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by camRun data_group", NULL); … … 83 85 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-sky_id", 0, "search by sky_id", 0); 84 86 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-skycal_id", 0, "search by skycal_id", 0); 87 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-diff_id", 0, "search by diff_id",0); 88 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-ff_id", 0, "search by _ff_id",0); 85 89 pxcamSetSearchArgs(updaterunArgs); 86 90 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by addRun label", NULL); … … 101 105 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by add_id", 0); 102 106 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 103 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack_id", 0); 104 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-sky_id", 0, "search by sky_id", 0); 105 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-skycal_id", 0, "search by skycal_id", 0); 107 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack_id", 0); 108 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-sky_id", 0, "search by sky_id", 0); 109 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-skycal_id", 0, "search by skycal_id", 0); 110 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-diff_id", 0, "search by diff_id",0); 111 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-ff_id", 0, "search by ff_id",0); 106 112 pxcamSetSearchArgs(pendingexpArgs); 107 113 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL); … … 236 242 psMetadata *modes = psMetadataAlloc(); 237 243 238 PXOPT_ADD_MODE("-definebyquery", "create runs from cam stage", ADDTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs);244 PXOPT_ADD_MODE("-definebyquery", "create runs from cam/skycal/forcedwarp/diff stage", ADDTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 239 245 PXOPT_ADD_MODE("-updaterun", "change add run properties", ADDTOOL_MODE_UPDATERUN, updaterunArgs); 240 246 PXOPT_ADD_MODE("-pendingexp", "show pending exps", ADDTOOL_MODE_PENDINGEXP, pendingexpArgs); -
trunk/ippTools/src/pxadd.c
r34265 r37551 164 164 psMemSetPersistent(query, true); 165 165 } 166 else if (strcmp(stage,"diff") == 0) { 167 query = pxDataGet("addtool_queue_diff_id.sql"); 168 psMemSetPersistent(query, true); 169 } 170 else if (strcmp(stage,"fullforce") == 0) { 171 query = pxDataGet("addtool_queue_ff_id.sql"); 172 psMemSetPersistent(query, true); 173 } 174 175 166 176 else 167 177 {
Note:
See TracChangeset
for help on using the changeset viewer.
