Changeset 7af652d in sasview for src/sas/sascalc/pr/invertor.py
- Timestamp:
- Mar 5, 2019 4:26:14 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1249
- Children:
- 1342f6a
- Parents:
- dbfd307 (diff), 8c9e65c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Paul Kienzle <pkienzle@…> (03/05/19 16:26:14)
- git-committer:
- GitHub <noreply@…> (03/05/19 16:26:14)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/invertor.py
rdbfd307 r7af652d 6 6 FIXME: The way the Invertor interacts with its C component should be cleaned up 7 7 """ 8 from __future__ import division 8 9 9 10 import numpy as np … … 17 18 from numpy.linalg import lstsq 18 19 from scipy import optimize 19 from sas.sascalc.pr. core.pr_inversion import Cinvertor20 from sas.sascalc.pr._pr_inversion import Cinvertor 20 21 21 22 logger = logging.getLogger(__name__) … … 71 72 A[j][i] = (Fourier transformed base function for point j) 72 73 73 We the mchoose a number of r-points, n_r, to evaluate the second74 We then choose a number of r-points, n_r, to evaluate the second 74 75 derivative of P(r) at. This is used as our regularization term. 75 76 For a vector r of length n_r, the following n_r rows are set to :: … … 144 145 x, y, err, d_max, q_min, q_max and alpha 145 146 """ 146 if 147 if name == 'x': 147 148 if 0.0 in value: 148 149 msg = "Invertor: one of your q-values is zero. " … … 268 269 A[i][j] = (Fourier transformed base function for point j) 269 270 270 We the mchoose a number of r-points, n_r, to evaluate the second271 We then choose a number of r-points, n_r, to evaluate the second 271 272 derivative of P(r) at. This is used as our regularization term. 272 273 For a vector r of length n_r, the following n_r rows are set to :: … … 416 417 A[i][j] = (Fourier transformed base function for point j) 417 418 418 We the mchoose a number of r-points, n_r, to evaluate the second419 We then choose a number of r-points, n_r, to evaluate the second 419 420 derivative of P(r) at. This is used as our regularization term. 420 421 For a vector r of length n_r, the following n_r rows are set to :: … … 498 499 try: 499 500 cov = np.linalg.pinv(inv_cov) 500 err = math.fabs(chi2 / float(npts - nfunc)) * cov501 except :501 err = math.fabs(chi2 / (npts - nfunc)) * cov 502 except Exception as exc: 502 503 # We were not able to estimate the errors 503 504 # Return an empty error matrix 504 logger.error( sys.exc_value)505 logger.error(exc) 505 506 506 507 # Keep a copy of the last output … … 539 540 540 541 """ 541 from num_term import NTermEstimator542 from .num_term import NTermEstimator 542 543 estimator = NTermEstimator(self.clone()) 543 544 try: 544 545 return estimator.num_terms(isquit_func) 545 except :546 except Exception as exc: 546 547 # If we fail, estimate alpha and return the default 547 548 # number of terms 548 549 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 549 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value)550 logger.warning("Invertor.estimate_numterms: %s" % exc) 550 551 return self.nfunc, best_alpha, "Could not estimate number of terms" 551 552 … … 633 634 return best_alpha, message, elapsed 634 635 635 except :636 message = "Invertor.estimate_alpha: %s" % sys.exc_value636 except Exception as exc: 637 message = "Invertor.estimate_alpha: %s" % exc 637 638 return 0, message, elapsed 638 639 … … 750 751 self.cov[i][i] = float(toks2[1]) 751 752 752 except :753 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value753 except Exception as exc: 754 msg = "Invertor.from_file: corrupted file\n%s" % exc 754 755 raise RuntimeError(msg) 755 756 else:
Note: See TracChangeset
for help on using the changeset viewer.