Changes in src/sas/sascalc/pr/invertor.py [9a5097c:463e7ffc] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/invertor.py
r9a5097c r463e7ffc 7 7 """ 8 8 9 import numpy as np9 import numpy 10 10 import sys 11 11 import math … … 18 18 from scipy import optimize 19 19 from sas.sascalc.pr.core.pr_inversion import Cinvertor 20 21 logger = logging.getLogger(__name__) 20 22 21 23 def help(): … … 189 191 #import numpy 190 192 if name == 'x': 191 out = n p.ones(self.get_nx())193 out = numpy.ones(self.get_nx()) 192 194 self.get_x(out) 193 195 return out 194 196 elif name == 'y': 195 out = n p.ones(self.get_ny())197 out = numpy.ones(self.get_ny()) 196 198 self.get_y(out) 197 199 return out 198 200 elif name == 'err': 199 out = n p.ones(self.get_nerr())201 out = numpy.ones(self.get_nerr()) 200 202 self.get_err(out) 201 203 return out … … 325 327 raise RuntimeError, msg 326 328 327 p = n p.ones(nfunc)329 p = numpy.ones(nfunc) 328 330 t_0 = time.time() 329 331 out, cov_x, _, _, _ = optimize.leastsq(self.residuals, p, full_output=1) … … 341 343 342 344 if cov_x is None: 343 cov_x = n p.ones([nfunc, nfunc])345 cov_x = numpy.ones([nfunc, nfunc]) 344 346 cov_x *= math.fabs(chisqr) 345 347 return out, cov_x … … 358 360 raise RuntimeError, msg 359 361 360 p = n p.ones(nfunc)362 p = numpy.ones(nfunc) 361 363 t_0 = time.time() 362 364 out, cov_x, _, _, _ = optimize.leastsq(self.pr_residuals, p, full_output=1) … … 435 437 """ 436 438 # Note: To make sure an array is contiguous: 437 # blah = n p.ascontiguousarray(blah_original)439 # blah = numpy.ascontiguousarray(blah_original) 438 440 # ... before passing it to C 439 441 … … 456 458 nfunc += 1 457 459 458 a = n p.zeros([npts + nq, nfunc])459 b = n p.zeros(npts + nq)460 err = n p.zeros([nfunc, nfunc])460 a = numpy.zeros([npts + nq, nfunc]) 461 b = numpy.zeros(npts + nq) 462 err = numpy.zeros([nfunc, nfunc]) 461 463 462 464 # Construct the a matrix and b vector that represent the problem … … 476 478 self.chi2 = chi2 477 479 478 inv_cov = n p.zeros([nfunc, nfunc])480 inv_cov = numpy.zeros([nfunc, nfunc]) 479 481 # Get the covariance matrix, defined as inv_cov = a_transposed * a 480 482 self._get_invcov_matrix(nfunc, nr, a, inv_cov) … … 490 492 491 493 try: 492 cov = n p.linalg.pinv(inv_cov)494 cov = numpy.linalg.pinv(inv_cov) 493 495 err = math.fabs(chi2 / float(npts - nfunc)) * cov 494 496 except: 495 497 # We were not able to estimate the errors 496 498 # Return an empty error matrix 497 logg ing.error(sys.exc_value)499 logger.error(sys.exc_value) 498 500 499 501 # Keep a copy of the last output … … 505 507 self.background = c[0] 506 508 507 err_0 = n p.zeros([nfunc, nfunc])508 c_0 = n p.zeros(nfunc)509 err_0 = numpy.zeros([nfunc, nfunc]) 510 c_0 = numpy.zeros(nfunc) 509 511 510 512 for i in range(nfunc_0): … … 541 543 # number of terms 542 544 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 543 logg ing.warning("Invertor.estimate_numterms: %s" % sys.exc_value)545 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 544 546 return self.nfunc, best_alpha, "Could not estimate number of terms" 545 547 … … 662 664 str(self.cov[i][i]))) 663 665 file.write("<r> <Pr> <dPr>\n") 664 r = n p.arange(0.0, self.d_max, self.d_max / npts)666 r = numpy.arange(0.0, self.d_max, self.d_max / npts) 665 667 666 668 for r_i in r: … … 694 696 toks = line.split('=') 695 697 self.nfunc = int(toks[1]) 696 self.out = n p.zeros(self.nfunc)697 self.cov = n p.zeros([self.nfunc, self.nfunc])698 self.out = numpy.zeros(self.nfunc) 699 self.cov = numpy.zeros([self.nfunc, self.nfunc]) 698 700 elif line.startswith('#alpha='): 699 701 toks = line.split('=')
Note: See TracChangeset
for help on using the changeset viewer.