Changeset 39079 for trunk/ippToPsps/jython/forcedgalaxybatch.py
- Timestamp:
- Nov 8, 2015, 11:24:21 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/forcedgalaxybatch.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/forcedgalaxybatch.py
r39075 r39079 138 138 for filter in filters: 139 139 filterID = self.scratchDb.getFilterID(filter[1]) 140 140 141 141 photcodeName = "NONE" 142 142 if self.config.camera == "gpc1": … … 144 144 if self.config.camera == "simtest": 145 145 photcodeName = "SIMTEST." + filter[1] + ".ForcedWarp" 146 146 147 147 photcode = self.scratchDb.getPhotcodeByName(photcodeName) 148 148 149 149 # This is going to need to join elsewhere to get all the fields? 150 150 # XforcedSummaryID, Ra, Dec, RaErr, DecErr 151 151 # Should GalChiSq fold in Npix somehow? 152 152 153 153 sqlLine = sqlUtility("UPDATE ForcedGalaxyShape AS a, " + cpqTable + " AS b SET") 154 154 sqlLine.group("a." + filter[1] + "ippDetectID", "b.DET_ID") … … 162 162 sqlLine.group("a." + filter[1] + "GalChisq", "b.CHISQ") 163 163 164 # we insert data for each of the possible model types, counting the number of filter/model values 165 # selected for each type. later we will delete rows for which nFilter is 0 166 sqlLine.group("a.nFilter", "a.nFilter + 1") 167 164 168 # These fields don't exist. 165 169 # sqlLine.group("a." + filter[1] + "GalRa", "b.RA") … … 167 171 # sqlLine.group("a." + filter[1] + "GalRaErr", "b.RA_ERR") 168 172 # sqlLine.group("a." + filter[1] + "GalDecErr", "b.DEC_ERR") 169 173 170 174 sql = sqlLine.makeEquals("WHERE a.ippObjID = (b.OBJ_ID + (b.CAT_ID << 32)) AND a.galModelType = b.MODEL_TYPE AND b.Photcode = " + str(photcode)) 171 175 172 176 self.logger.debugPair("cpq sql: ", sql) 173 177 174 178 self.scratchDb.execute(sql) 175 179 … … 183 187 184 188 self.logger.info("Populating ForcedGalaxyShape") 185 self.logger.info("Inserting from cpq file") 186 187 sqlLine = sqlUtility("INSERT INTO ForcedGalaxyShape (") 188 189 sqlLine.group("objID", "EXT_ID") 190 # uniquePspsFGid is set elsewhere 191 sqlLine.group("ippObjID", "OBJ_ID + (CAT_ID << 32)") 192 # batchID isn't in the schema, should it be? 193 # sqlLine.group("batchID", "'" + str(self.batchID) + "'") 194 # surveyID is set where? 195 sqlLine.group("randomForcedGalID", "RAND("+str(self.batchID)+")") 196 197 sql = sqlLine.makeRaw(") SELECT ", " FROM " + cptTableName) 198 199 print "--- sql: " + sql 200 189 190 # the cpt file has the basic object data (IDs). insert a row for each of the 191 # model types of interest, listed in the array below 192 self.logger.info("Inserting from cpt file") 193 for modelName in ["PS_MODEL_EXP", "PS_MODEL_DEV", "PS_MODEL_SERSIC"]: 194 modelID = self.scratchDb.getFitModelID(modelName) 195 ## assert on modelID > 0 196 197 sqlLine = sqlUtility("INSERT INTO ForcedGalaxyShape (") 198 199 # uniquePspsFGid is set elsewhere 200 # batchID isn't in the schema, should it be? 201 202 sqlLine.group("objID", "EXT_ID") 203 sqlLine.group("ippObjID", "OBJ_ID + (CAT_ID << 32)") 204 sqlLine.group("surveyID", str(self.surveyID)) 205 sqlLine.group("randomForcedGalID", "RAND("+str(self.batchID)+")") 206 sqlLine.group("nFilter", "0") 207 sqlLine.group("galModelType", str(modelID)) 208 209 sql = sqlLine.makeRaw(") SELECT ", " FROM " + cptTableName) 210 211 print "--- sql: " + sql 212 213 self.scratchDb.execute(sql) 214 215 # add in the actual galaxy photometry & shape measurements 216 self.logger.infoPair("update ForcedGalaxyShape from ","cpq table") 217 self.updateForcedGalaxyShapeFromCpq(cpqTableName) 218 219 # drop the rows with no galaxy photometry 220 self.logger.infoPair("dropping rows with no data", "ForcedGalaxyShape") 221 sql = "DELETE FROM ForcedGalaxyShape WHERE nFilter = 0" 201 222 self.scratchDb.execute(sql) 202 223 203 self.logger.infoPair("Adding 'row' columns to", "Forced Galaxy, cpt tables") 224 # now we need to generate a unique psps ID: 225 self.logger.infoPair("Adding 'row' columns to", "ForcedGalaxyShape table") 204 226 self.scratchDb.addRowCountColumn("ForcedGalaxyShape", "row") 205 self.scratchDb.addRowCountColumn(cpqTableName, "row")206 227 207 228 self.logger.infoPair("generating unique ids for ","ForcedGalaxyShape") 208 229 self.updatePspsUniqueIDs() 209 230 210 self.logger.infoPair("update ForcedGalaxyShape from ","cpq table")211 self.updateForcedGalaxyShapeFromCpq(cpqTableName)212 213 231 self.logger.infoPair("Dropping row column from ", "ForcedGalaxyShape table") 214 232 self.scratchDb.dropColumn("ForcedGalaxyShape", "row") … … 216 234 self.logger.infoPair("setting minmaxobjid for ", "ForcedGalaxyShape table") 217 235 self.setMinMaxObjID(["ForcedGalaxyShape"]) 236 218 237 self.logger.infoPair("checking if we have detections", "ForcedGalaxyShape table") 219 220 238 rowcount = self.scratchDb.getRowCount("ForcedGalaxyShape") 221 239
Note:
See TracChangeset
for help on using the changeset viewer.
