- Timestamp:
- Jan 11, 2012, 11:19:21 PM (15 years ago)
- Location:
- branches/meh_branches/ppsub_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/scratchdb.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppsub_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppsub_test/ippToPsps/jython/scratchdb.py
r32062 r33098 41 41 42 42 ''' 43 Creates a stored procedure for psfLikelihood. This uses an implementation of the complimentary error function taken from Numerical Recipes in C. 44 ''' 45 def createPsfLikelihoodFunction(self): 46 47 sql = "DROP FUNCTION IF EXISTS `psfLikelihood`" 48 try: 49 self.execute(sql) 50 except: 51 self.logger.errorPair("Could not drop stored procedure", "psfLikelihood") 52 return False 53 54 sql = "CREATE FUNCTION `psfLikelihood`(x REAL) RETURNS REAL \ 55 DETERMINISTIC \ 56 COMMENT 'Returns the psfLikelihood using the complimentary error function with fractional error everywhere less than 1.2 x 10-7. From Numerical Recipes in C' \ 57 BEGIN \ 58 DECLARE ans REAL; \ 59 DECLARE t REAL; \ 60 DECLARE z REAL; \ 61 SET x = ABS(x) / 1.4142135623731; \ 62 SET z=ABS(x); \ 63 SET t=1.0 / (1.0 + 0.5*z); \ 64 SET ans = t * EXP(-z*z-1.26551223+t*(1.00002368+t*(.37409196+t*(.09678418+t*(-.18628806+t*(.27886807+t*(-1.13520398+t*(1.48851587+t*(-.82215223+t*.17087277))))))))); \ 65 IF x < 0.0 THEN \ 66 SET ans = 2.0 - ans; \ 67 END IF; \ 68 RETURN ans; \ 69 END" 70 71 try: 72 self.execute(sql) 73 self.logger.debugPair("Installed stored procedure", "psfLikelihood") 74 return True 75 except: 76 self.logger.errorPair("Could not install stored procedure", "psfLikelihood") 77 return False 78 79 ''' 43 80 Gets survey ID for this survey name 44 81 ''' … … 55 92 56 93 return surveyID 94 95 ''' 96 Gets filter ID for this filter name 97 ''' 98 def getFilterID(self, name): 99 100 sql = "SELECT filterID FROM Filter WHERE filterType = '" + name + "'" 101 try: 102 rs = self.executeQuery(sql) 103 rs.first() 104 filterID = rs.getInt(1) 105 except: 106 self.logger.errorPair("No filter ID found for filter", name) 107 filterID = -1 108 109 return filterID 57 110 58 111 ''' … … 137 190 138 191 ''' 192 Checks whether the astrometric solution is ok for this chip 193 TODO the value of 50 for numAstroRef is hardcoded here, but this should be temporary anyway 194 ''' 195 def astrometricSolutionOK(self, ota): 196 197 sql = "SELECT numAstroRef FROM ImageMeta_" + ota 198 199 try: 200 rs = self.executeQuery(sql) 201 rs.first() 202 if rs.getInt(1) < 50: 203 self.logger.debug("Bad astrometric solution for", ota) 204 return False 205 else: 206 return True 207 except: 208 self.logger.debug("Unable to check astrometric solution") 209 210 return True 211 212 ''' 139 213 Have we already imported this DVO table? 140 214 '''
Note:
See TracChangeset
for help on using the changeset viewer.
