Changeset 952ea1f in sasview for src/sas/sascalc
- Timestamp:
- Oct 11, 2018 11:33:22 AM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
- Children:
- 7ba6470
- Parents:
- 67ed543
- git-author:
- Paul Kienzle <pkienzle@…> (10/11/18 11:22:07)
- git-committer:
- Paul Kienzle <pkienzle@…> (10/11/18 11:33:22)
- Location:
- src/sas/sascalc
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/c_extensions/sld2i_module.c
ra1daf86 r952ea1f 2 2 SLD2I module to perform point and I calculations 3 3 */ 4 #include <stdio.h> 5 6 //#define Py_LIMITED_API 0x03020000 4 7 #include <Python.h> 5 #include <stdio.h> 8 6 9 #include "sld2i.h" 7 10 … … 160 163 161 164 #define MODULE_DOC "Sld2i C Library" 162 #define MODULE_NAME " sld2i"163 #define MODULE_INIT2 init sld2i164 #define MODULE_INIT3 PyInit_ sld2i165 #define MODULE_NAME "_sld2i" 166 #define MODULE_INIT2 init_sld2i 167 #define MODULE_INIT3 PyInit__sld2i 165 168 #define MODULE_METHODS module_methods 166 169 -
src/sas/sascalc/calculator/sas_gen.py
r144e032a r952ea1f 14 14 import numpy as np 15 15 16 from . core import sld2i as mod16 from . import _sld2i 17 17 from .BaseComponent import BaseComponent 18 18 … … 145 145 self.params['Up_frac_out'], 146 146 self.params['Up_theta']) 147 model = mod.new_GenI(*args)147 model = _sld2i.new_GenI(*args) 148 148 if len(qy): 149 149 qx, qy = _vec(qx), _vec(qy) 150 150 I_out = np.empty_like(qx) 151 151 #print("npoints", qx.shape, "npixels", pos_x.shape) 152 mod.genicomXY(model, qx, qy, I_out)152 _sld2i.genicomXY(model, qx, qy, I_out) 153 153 #print("I_out after", I_out) 154 154 else: 155 155 qx = _vec(qx) 156 156 I_out = np.empty_like(qx) 157 mod.genicom(model, qx, I_out)157 _sld2i.genicom(model, qx, I_out) 158 158 vol_correction = self.data_total_volume / self.params['total_volume'] 159 159 result = (self.params['scale'] * vol_correction * I_out … … 304 304 z_dir2 *= z_dir2 305 305 mask = (x_dir2 + y_dir2 + z_dir2) <= 1.0 306 except Exception :307 logger.error( sys.exc_value)306 except Exception as exc: 307 logger.error(exc) 308 308 self.output = MagSLD(self.pos_x[mask], self.pos_y[mask], 309 309 self.pos_z[mask], self.sld_n[mask], … … 600 600 y_lines.append(y_line) 601 601 z_lines.append(z_line) 602 except Exception :603 logger.error( sys.exc_value)602 except Exception as exc: 603 logger.error(exc) 604 604 605 605 output = MagSLD(pos_x, pos_y, pos_z, sld_n, sld_mx, sld_my, sld_mz) … … 691 691 _vol_pix = float(toks[7]) 692 692 vol_pix = np.append(vol_pix, _vol_pix) 693 except Exception :693 except Exception as exc: 694 694 vol_pix = None 695 except Exception :695 except Exception as exc: 696 696 # Skip non-data lines 697 logger.error( sys.exc_value)697 logger.error(exc) 698 698 output = MagSLD(pos_x, pos_y, pos_z, sld_n, 699 699 sld_mx, sld_my, sld_mz) -
src/sas/sascalc/file_converter/bsl_loader.py
rf00691d4 r952ea1f 1 from sas.sascalc.file_converter. core.bsl_loader import CLoader1 from sas.sascalc.file_converter._bsl_loader import CLoader 2 2 from sas.sascalc.dataloader.data_info import Data2D 3 3 from copy import deepcopy … … 67 67 'swap_bytes': int(metadata[3]) 68 68 } 69 except :69 except Exception: 70 70 is_valid = False 71 71 err_msg = "Invalid metadata in header file for {}" -
src/sas/sascalc/file_converter/c_ext/bsl_loader.c
rd5aeaa3 r952ea1f 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 //#define Py_LIMITED_API 0x03020000 1 5 #include <Python.h> 6 #include <structmember.h> 2 7 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 3 8 #include <numpy/arrayobject.h> 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include "structmember.h" 9 7 10 #include "bsl_loader.h" 8 11 … … 292 295 293 296 #define MODULE_DOC "C module for loading bsl." 294 #define MODULE_NAME " bsl_loader"295 #define MODULE_INIT2 init bsl_loader296 #define MODULE_INIT3 PyInit_ bsl_loader297 #define MODULE_NAME "_bsl_loader" 298 #define MODULE_INIT2 init_bsl_loader 299 #define MODULE_INIT3 PyInit__bsl_loader 297 300 #define MODULE_METHODS module_methods 298 301 -
src/sas/sascalc/pr/c_extensions/Cinvertor.c
ra52f32f r952ea1f 5 5 * 6 6 */ 7 #include <Python.h>8 #include "structmember.h"9 7 #include <stdio.h> 10 8 #include <stdlib.h> … … 12 10 #include <time.h> 13 11 12 //#define Py_LIMITED_API 0x03050000 13 #include <Python.h> 14 #include <structmember.h> 15 14 16 #include "invertor.h" 15 16 17 17 18 /// Error object for raised exceptions … … 1121 1122 1122 1123 #define MODULE_DOC "C extension module for inversion to P(r)." 1123 #define MODULE_NAME " pr_inversion"1124 #define MODULE_INIT2 init pr_inversion1125 #define MODULE_INIT3 PyInit_ pr_inversion1124 #define MODULE_NAME "_pr_inversion" 1125 #define MODULE_INIT2 init_pr_inversion 1126 #define MODULE_INIT3 PyInit__pr_inversion 1126 1127 #define MODULE_METHODS module_methods 1127 1128 -
src/sas/sascalc/pr/invertor.py
r2469df7 r952ea1f 17 17 from numpy.linalg import lstsq 18 18 from scipy import optimize 19 from sas.sascalc.pr. core.pr_inversion import Cinvertor19 from sas.sascalc.pr._pr_inversion import Cinvertor 20 20 21 21 logger = logging.getLogger(__name__) … … 71 71 A[j][i] = (Fourier transformed base function for point j) 72 72 73 We the mchoose a number of r-points, n_r, to evaluate the second73 We then choose a number of r-points, n_r, to evaluate the second 74 74 derivative of P(r) at. This is used as our regularization term. 75 75 For a vector r of length n_r, the following n_r rows are set to :: … … 144 144 x, y, err, d_max, q_min, q_max and alpha 145 145 """ 146 if 146 if name == 'x': 147 147 if 0.0 in value: 148 148 msg = "Invertor: one of your q-values is zero. " … … 268 268 A[i][j] = (Fourier transformed base function for point j) 269 269 270 We the mchoose a number of r-points, n_r, to evaluate the second270 We then choose a number of r-points, n_r, to evaluate the second 271 271 derivative of P(r) at. This is used as our regularization term. 272 272 For a vector r of length n_r, the following n_r rows are set to :: … … 416 416 A[i][j] = (Fourier transformed base function for point j) 417 417 418 We the mchoose a number of r-points, n_r, to evaluate the second418 We then choose a number of r-points, n_r, to evaluate the second 419 419 derivative of P(r) at. This is used as our regularization term. 420 420 For a vector r of length n_r, the following n_r rows are set to :: … … 473 473 474 474 # Perform the inversion (least square fit) 475 c, chi2, _, _ = lstsq(a, b )475 c, chi2, _, _ = lstsq(a, b, rcond=None) 476 476 # Sanity check 477 477 try: … … 497 497 cov = np.linalg.pinv(inv_cov) 498 498 err = math.fabs(chi2 / float(npts - nfunc)) * cov 499 except :499 except Exception as exc: 500 500 # We were not able to estimate the errors 501 501 # Return an empty error matrix 502 logger.error( sys.exc_value)502 logger.error(exc) 503 503 504 504 # Keep a copy of the last output … … 537 537 538 538 """ 539 from num_term import NTermEstimator539 from .num_term import NTermEstimator 540 540 estimator = NTermEstimator(self.clone()) 541 541 try: 542 542 return estimator.num_terms(isquit_func) 543 except :543 except Exception as exc: 544 544 # If we fail, estimate alpha and return the default 545 545 # number of terms 546 546 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 547 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value)547 logger.warning("Invertor.estimate_numterms: %s" % exc) 548 548 return self.nfunc, best_alpha, "Could not estimate number of terms" 549 549 … … 631 631 return best_alpha, message, elapsed 632 632 633 except :634 message = "Invertor.estimate_alpha: %s" % sys.exc_value633 except Exception as exc: 634 message = "Invertor.estimate_alpha: %s" % exc 635 635 return 0, message, elapsed 636 636 … … 748 748 self.cov[i][i] = float(toks2[1]) 749 749 750 except :751 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value750 except Exception as exc: 751 msg = "Invertor.from_file: corrupted file\n%s" % exc 752 752 raise RuntimeError(msg) 753 753 else:
Note: See TracChangeset
for help on using the changeset viewer.