Changes in src/sas/sascalc/pr/invertor.py [57e48ca:2469df7] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/invertor.py
r57e48ca r2469df7 6 6 FIXME: The way the Invertor interacts with its C component should be cleaned up 7 7 """ 8 from __future__ import division9 8 10 9 import numpy as np … … 18 17 from numpy.linalg import lstsq 19 18 from scipy import optimize 20 from sas.sascalc.pr. _pr_inversion import Cinvertor19 from sas.sascalc.pr.core.pr_inversion import Cinvertor 21 20 22 21 logger = logging.getLogger(__name__) … … 72 71 A[j][i] = (Fourier transformed base function for point j) 73 72 74 We the nchoose a number of r-points, n_r, to evaluate the second73 We them choose a number of r-points, n_r, to evaluate the second 75 74 derivative of P(r) at. This is used as our regularization term. 76 75 For a vector r of length n_r, the following n_r rows are set to :: … … 145 144 x, y, err, d_max, q_min, q_max and alpha 146 145 """ 147 if name == 'x':146 if name == 'x': 148 147 if 0.0 in value: 149 148 msg = "Invertor: one of your q-values is zero. " … … 269 268 A[i][j] = (Fourier transformed base function for point j) 270 269 271 We the nchoose a number of r-points, n_r, to evaluate the second270 We them choose a number of r-points, n_r, to evaluate the second 272 271 derivative of P(r) at. This is used as our regularization term. 273 272 For a vector r of length n_r, the following n_r rows are set to :: … … 417 416 A[i][j] = (Fourier transformed base function for point j) 418 417 419 We the nchoose a number of r-points, n_r, to evaluate the second418 We them choose a number of r-points, n_r, to evaluate the second 420 419 derivative of P(r) at. This is used as our regularization term. 421 420 For a vector r of length n_r, the following n_r rows are set to :: … … 474 473 475 474 # Perform the inversion (least square fit) 476 c, chi2, _, _ = lstsq(a, b , rcond=-1)475 c, chi2, _, _ = lstsq(a, b) 477 476 # Sanity check 478 477 try: … … 497 496 try: 498 497 cov = np.linalg.pinv(inv_cov) 499 err = math.fabs(chi2 / (npts - nfunc)) * cov500 except Exception as exc:498 err = math.fabs(chi2 / float(npts - nfunc)) * cov 499 except: 501 500 # We were not able to estimate the errors 502 501 # Return an empty error matrix 503 logger.error( exc)502 logger.error(sys.exc_value) 504 503 505 504 # Keep a copy of the last output … … 538 537 539 538 """ 540 from .num_term import NTermEstimator539 from num_term import NTermEstimator 541 540 estimator = NTermEstimator(self.clone()) 542 541 try: 543 542 return estimator.num_terms(isquit_func) 544 except Exception as exc:543 except: 545 544 # If we fail, estimate alpha and return the default 546 545 # number of terms 547 546 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 548 logger.warning("Invertor.estimate_numterms: %s" % exc)547 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 549 548 return self.nfunc, best_alpha, "Could not estimate number of terms" 550 549 … … 632 631 return best_alpha, message, elapsed 633 632 634 except Exception as exc:635 message = "Invertor.estimate_alpha: %s" % exc633 except: 634 message = "Invertor.estimate_alpha: %s" % sys.exc_value 636 635 return 0, message, elapsed 637 636 … … 749 748 self.cov[i][i] = float(toks2[1]) 750 749 751 except Exception as exc:752 msg = "Invertor.from_file: corrupted file\n%s" % exc750 except: 751 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 753 752 raise RuntimeError(msg) 754 753 else:
Note: See TracChangeset
for help on using the changeset viewer.