Changeset 32295
- Timestamp:
- Sep 2, 2011, 11:43:24 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/scratchdb.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/scratchdb.py
r32179 r32295 39 39 40 40 self.logger.debug("ScratchDb destructor") 41 42 43 ''' 44 Creates stored procedure for psfLikelihood 45 ''' 46 def createPsfLikelihoodFunction(self): 47 sql = "DELIMITER $$ \ 48 DROP FUNCTION IF EXISTS `psfLikelihood` $$ \ 49 CREATE FUNCTION `psfLikelihood`(x REAL) RETURNS REAL \ 50 DETERMINISTIC \ 51 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' \ 52 BEGIN \ 53 DECLARE ans REAL; \ 54 DECLARE t REAL; \ 55 DECLARE z REAL; \ 56 SET x = ABS(x) / 1.4142135623731; \ 57 SET z=ABS(x); \ 58 SET t=1.0 / (1.0 + 0.5*z); \ 59 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))))))))); \ 60 IF x < 0.0 THEN \ 61 SET ans = 2.0 - ans; \ 62 END IF; \ 63 RETURN ans; \ 64 END $$ \ 65 DELIMITER ;" 66 67 try: 68 self.execute(sql) 69 self.logger.debugPair("Installed stored procedure", "psfLikelihood") 70 return True 71 except: 72 self.logger.errorPair("Could not install stored procedure", "psfLikelihood") 73 return False 41 74 42 75 '''
Note:
See TracChangeset
for help on using the changeset viewer.
