- 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)
- Location:
- src/sas
- Files:
-
- 4 added
- 5 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/_config.py
rb963b20 r93b34cc 86 86 def setup_custom_config(app_dir, user_dir): 87 87 path = make_custom_config_path(user_dir) 88 #logger.info("custom config path %s", path) 88 89 if not os.path.isfile(path): 89 90 try: … … 94 95 logger.error("Could not copy default custom config.") 95 96 97 custom_config = load_custom_config(path) 98 96 99 #Adding SAS_OPENCL if it doesn't exist in the config file 97 100 # - to support backcompability 98 if not "SAS_OPENCL" in open(path).read(): 101 if not hasattr(custom_config, "SAS_OPENCL"): 102 custom_config.SAS_OPENCL = None 99 103 try: 100 open( config_file, "a+").write("SAS_OPENCL = \"None\"\n")104 open(path, "a+").write("SAS_OPENCL = \"None\"\n") 101 105 except Exception: 102 106 logger.error("Could not update custom config with SAS_OPENCL.") 103 107 104 custom_config = load_custom_config(path)105 108 return custom_config 106 107 109 108 110 def load_custom_config(path): -
src/sas/sascalc/calculator/c_extensions/sld2i_module.c
ra1daf86 r7ba6470 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 … … 13 16 #endif 14 17 15 16 // Utilities 17 #define INVECTOR(obj,buf,len) \ 18 do { \ 19 int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \ 20 if (err < 0) return NULL; \ 21 len /= sizeof(*buf); \ 22 } while (0) 23 24 #define OUTVECTOR(obj,buf,len) \ 25 do { \ 26 int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \ 27 if (err < 0) return NULL; \ 28 len /= sizeof(*buf); \ 29 } while (0) 30 18 // Vector binding glue 19 #if (PY_VERSION_HEX > 0x03000000) && !defined(Py_LIMITED_API) 20 // Assuming that a view into a writable vector points to a 21 // non-changing pointer for the duration of the C call, capture 22 // the view pointer and immediately free the view. 23 #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \ 24 Py_buffer VEC_view; \ 25 int VEC_err = PyObject_GetBuffer(VEC_obj, &VEC_view, PyBUF_WRITABLE|PyBUF_FORMAT); \ 26 if (VEC_err < 0 || sizeof(*VEC_buf) != VEC_view.itemsize) return NULL; \ 27 VEC_buf = (typeof(VEC_buf))VEC_view.buf; \ 28 VEC_len = VEC_view.len/sizeof(*VEC_buf); \ 29 PyBuffer_Release(&VEC_view); \ 30 } while (0) 31 #else 32 #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \ 33 int VEC_err = PyObject_AsWriteBuffer(VEC_obj, (void **)(&VEC_buf), &VEC_len); \ 34 if (VEC_err < 0) return NULL; \ 35 VEC_len /= sizeof(*VEC_buf); \ 36 } while (0) 37 #endif 31 38 32 39 /** … … 73 80 //printf("new GenI\n"); 74 81 if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &is_avg, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL; 75 INVECTOR(x_val_obj, x_val, n_x);76 INVECTOR(y_val_obj, y_val, n_y);77 INVECTOR(z_val_obj, z_val, n_z);78 INVECTOR(sldn_val_obj, sldn_val, n_sld);79 INVECTOR(mx_val_obj, mx_val, n_mx);80 INVECTOR(my_val_obj, my_val, n_my);81 INVECTOR(mz_val_obj, mz_val, n_mz);82 INVECTOR(vol_pix_obj, vol_pix, n_vol_pix);82 VECTOR(x_val_obj, x_val, n_x); 83 VECTOR(y_val_obj, y_val, n_y); 84 VECTOR(z_val_obj, z_val, n_z); 85 VECTOR(sldn_val_obj, sldn_val, n_sld); 86 VECTOR(mx_val_obj, mx_val, n_mx); 87 VECTOR(my_val_obj, my_val, n_my); 88 VECTOR(mz_val_obj, mz_val, n_mz); 89 VECTOR(vol_pix_obj, vol_pix, n_vol_pix); 83 90 sld2i = PyMem_Malloc(sizeof(GenI)); 84 91 //printf("sldi:%p\n", sld2i); … … 108 115 if (!PyArg_ParseTuple(args, "OOOO", &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL; 109 116 sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 110 INVECTOR(qx_obj, qx, n_qx);111 INVECTOR(qy_obj, qy, n_qy);112 OUTVECTOR(I_out_obj, I_out, n_out);117 VECTOR(qx_obj, qx, n_qx); 118 VECTOR(qy_obj, qy, n_qy); 119 VECTOR(I_out_obj, I_out, n_out); 113 120 //printf("qx, qy, I_out: %d %d %d, %d %d %d\n", qx, qy, I_out, n_qx, n_qy, n_out); 114 121 … … 136 143 if (!PyArg_ParseTuple(args, "OOO", &gen_obj, &q_obj, &I_out_obj)) return NULL; 137 144 sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI"); 138 INVECTOR(q_obj, q, n_q);139 OUTVECTOR(I_out_obj, I_out, n_out);145 VECTOR(q_obj, q, n_q); 146 VECTOR(I_out_obj, I_out, n_out); 140 147 141 148 // Sanity check … … 160 167 161 168 #define MODULE_DOC "Sld2i C Library" 162 #define MODULE_NAME " sld2i"163 #define MODULE_INIT2 init sld2i164 #define MODULE_INIT3 PyInit_ sld2i169 #define MODULE_NAME "_sld2i" 170 #define MODULE_INIT2 init_sld2i 171 #define MODULE_INIT3 PyInit__sld2i 165 172 #define MODULE_METHODS module_methods 166 173 -
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/corfunc/transform_thread.py
ra859f99 ref74a8b 45 45 # gamma3(R) = 1/R int_{0}^{R} gamma1(x) dx 46 46 # trapz uses the trapezium rule to calculate the integral 47 mask = xs <= 200.0 # Only calculate gamma3 up to x=200 (as this is all that's plotted)47 mask = xs <= 1000.0 # Only calculate gamma3 up to x=1000 (as this is all that's plotted) 48 48 # gamma3 = [trapz(gamma1[:n], xs[:n])/xs[n-1] for n in range(2, len(xs[mask]) + 1)]j 49 49 # gamma3.insert(0, 1.0) # Gamma_3(0) is defined as 1 … … 79 79 80 80 transform1 = Data1D(xs, gamma1) 81 transform3 = Data1D(xs[xs <= 200], gamma3)81 transform3 = Data1D(xs[xs <= 1000], gamma3) 82 82 idf = Data1D(xs, idf) 83 83 -
src/sas/sascalc/data_util/nxsunit.py
re090ba90 r8c9e65c 135 135 sld = { '10^-6 Angstrom^-2': 1e-6, 'Angstrom^-2': 1 } 136 136 Q = { 'invA': 1, 'invAng': 1, 'invAngstroms': 1, '1/A': 1, 137 '1/Angstrom': 1, '1/angstrom': 1, 'A^{-1}': 1, 'cm^{-1}': 1e-8, 137 138 '10^-3 Angstrom^-1': 1e-3, '1/cm': 1e-8, '1/m': 1e-10, 138 'nm^ -1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1 }139 'nm^{-1}': 1, 'nm^-1': 0.1, '1/nm': 0.1, 'n_m^-1': 0.1 } 139 140 140 141 _caret_optional(sld) … … 156 157 # units for that particular dimension. 157 158 # Note: don't have support for dimensionless units. 158 unknown = {None:1, '???':1, '': 1, 'a.u.': 1 }159 unknown = {None:1, '???':1, '': 1, 'a.u.': 1, 'Counts': 1, 'counts': 1} 159 160 160 161 def __init__(self, name): -
src/sas/sascalc/dataloader/data_info.py
re090ba90 r8c9e65c 957 957 _str += "Data:\n" 958 958 _str += " Type: %s\n" % self.__class__.__name__ 959 _str += " X- & Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 959 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 960 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 960 961 _str += " Z-axis: %s\t[%s]\n" % (self._zaxis, self._zunit) 961 962 _str += " Length: %g \n" % (len(self.data)) … … 986 987 qx_data=qx_data, qy_data=qy_data, 987 988 q_data=q_data, mask=mask) 989 990 clone._xaxis = self._xaxis 991 clone._yaxis = self._yaxis 992 clone._zaxis = self._zaxis 993 clone._xunit = self._xunit 994 clone._yunit = self._yunit 995 clone._zunit = self._zunit 996 clone.x_bins = self.x_bins 997 clone.y_bins = self.y_bins 988 998 989 999 clone.title = self.title … … 1156 1166 def combine_data_info_with_plottable(data, datainfo): 1157 1167 """ 1158 A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object. 1168 A function that combines the DataInfo data in self.current_datainto with a 1169 plottable_1D or 2D data object. 1159 1170 1160 1171 :param data: A plottable_1D or plottable_2D data object … … 1174 1185 final_dataset.yaxis(data._yaxis, data._yunit) 1175 1186 elif isinstance(data, plottable_2D): 1176 final_dataset = Data2D(data.data, data.err_data, data.qx_data, data.qy_data, data.q_data, 1177 data.mask, data.dqx_data, data.dqy_data) 1187 final_dataset = Data2D(data.data, data.err_data, data.qx_data, 1188 data.qy_data, data.q_data, data.mask, 1189 data.dqx_data, data.dqy_data) 1178 1190 final_dataset.xaxis(data._xaxis, data._xunit) 1179 1191 final_dataset.yaxis(data._yaxis, data._yunit) 1180 1192 final_dataset.zaxis(data._zaxis, data._zunit) 1181 if len(data.data.shape) == 2: 1182 n_rows, n_cols = data.data.shape 1183 final_dataset.y_bins = data.qy_data[0::int(n_cols)] 1184 final_dataset.x_bins = data.qx_data[:int(n_cols)] 1193 final_dataset.y_bins = data.y_bins 1194 final_dataset.x_bins = data.x_bins 1185 1195 else: 1186 return_string = "Should Never Happen: _combine_data_info_with_plottable input is not a plottable1d or " + \ 1187 "plottable2d data object" 1196 return_string = ("Should Never Happen: _combine_data_info_with_plottabl" 1197 "e input is not a plottable1d or plottable2d data " 1198 "object") 1188 1199 return return_string 1189 1200 -
src/sas/sascalc/dataloader/file_reader_base_class.py
r4a8d55c rc222c27 16 16 from .data_info import Data1D, Data2D, DataInfo, plottable_1D, plottable_2D,\ 17 17 combine_data_info_with_plottable 18 from sas.sascalc.data_util.nxsunit import Converter 18 19 19 20 logger = logging.getLogger(__name__) … … 37 38 "SasView cannot guarantee the accuracy of the data.") 38 39 40 39 41 class FileReader(object): 40 42 # String to describe the type of data this reader can load … … 45 47 ext = ['.txt'] 46 48 # Deprecated extensions 47 deprecated_extensions = ['.asc' , '.nxs']49 deprecated_extensions = ['.asc'] 48 50 # Bypass extension check and try to load anyway 49 51 allow_all = False … … 98 100 if len(self.output) > 0: 99 101 # Sort the data that's been loaded 100 self. sort_one_d_data()101 self.sort_ two_d_data()102 self.convert_data_units() 103 self.sort_data() 102 104 else: 103 105 msg = "Unable to find file at: {}\n".format(filepath) … … 140 142 Returns the entire file as a string. 141 143 """ 142 #return self.f_open.read()143 144 return decode(self.f_open.read()) 144 145 … … 166 167 self.output.append(data_obj) 167 168 168 def sort_ one_d_data(self):169 def sort_data(self): 169 170 """ 170 171 Sort 1D data along the X axis for consistency … … 174 175 # Normalize the units for 175 176 data.x_unit = self.format_unit(data.x_unit) 177 data._xunit = data.x_unit 176 178 data.y_unit = self.format_unit(data.y_unit) 179 data._yunit = data.y_unit 177 180 # Sort data by increasing x and remove 1st point 178 181 ind = np.lexsort((data.y, data.x)) … … 203 206 data.ymin = np.min(data.y) 204 207 data.ymax = np.max(data.y) 208 elif isinstance(data, Data2D): 209 # Normalize the units for 210 data.Q_unit = self.format_unit(data.Q_unit) 211 data.I_unit = self.format_unit(data.I_unit) 212 data._xunit = data.Q_unit 213 data._yunit = data.Q_unit 214 data._zunit = data.I_unit 215 data.data = data.data.astype(np.float64) 216 data.qx_data = data.qx_data.astype(np.float64) 217 data.xmin = np.min(data.qx_data) 218 data.xmax = np.max(data.qx_data) 219 data.qy_data = data.qy_data.astype(np.float64) 220 data.ymin = np.min(data.qy_data) 221 data.ymax = np.max(data.qy_data) 222 data.q_data = np.sqrt(data.qx_data * data.qx_data 223 + data.qy_data * data.qy_data) 224 if data.err_data is not None: 225 data.err_data = data.err_data.astype(np.float64) 226 if data.dqx_data is not None: 227 data.dqx_data = data.dqx_data.astype(np.float64) 228 if data.dqy_data is not None: 229 data.dqy_data = data.dqy_data.astype(np.float64) 230 if data.mask is not None: 231 data.mask = data.mask.astype(dtype=bool) 232 233 if len(data.data.shape) == 2: 234 n_rows, n_cols = data.data.shape 235 data.y_bins = data.qy_data[0::int(n_cols)] 236 data.x_bins = data.qx_data[:int(n_cols)] 237 data.data = data.data.flatten() 238 data = self._remove_nans_in_data(data) 239 if len(data.data) > 0: 240 data.xmin = np.min(data.qx_data) 241 data.xmax = np.max(data.qx_data) 242 data.ymin = np.min(data.qy_data) 243 data.ymax = np.max(data.qy_data) 205 244 206 245 @staticmethod … … 242 281 return data 243 282 244 def sort_two_d_data(self): 245 for dataset in self.output: 246 if isinstance(dataset, Data2D): 247 # Normalize the units for 248 dataset.x_unit = self.format_unit(dataset.Q_unit) 249 dataset.y_unit = self.format_unit(dataset.I_unit) 250 dataset.data = dataset.data.astype(np.float64) 251 dataset.qx_data = dataset.qx_data.astype(np.float64) 252 dataset.xmin = np.min(dataset.qx_data) 253 dataset.xmax = np.max(dataset.qx_data) 254 dataset.qy_data = dataset.qy_data.astype(np.float64) 255 dataset.ymin = np.min(dataset.qy_data) 256 dataset.ymax = np.max(dataset.qy_data) 257 dataset.q_data = np.sqrt(dataset.qx_data * dataset.qx_data 258 + dataset.qy_data * dataset.qy_data) 259 if dataset.err_data is not None: 260 dataset.err_data = dataset.err_data.astype(np.float64) 261 if dataset.dqx_data is not None: 262 dataset.dqx_data = dataset.dqx_data.astype(np.float64) 263 if dataset.dqy_data is not None: 264 dataset.dqy_data = dataset.dqy_data.astype(np.float64) 265 if dataset.mask is not None: 266 dataset.mask = dataset.mask.astype(dtype=bool) 267 268 if len(dataset.data.shape) == 2: 269 n_rows, n_cols = dataset.data.shape 270 dataset.y_bins = dataset.qy_data[0::int(n_cols)] 271 dataset.x_bins = dataset.qx_data[:int(n_cols)] 272 dataset.data = dataset.data.flatten() 273 dataset = self._remove_nans_in_data(dataset) 274 if len(dataset.data) > 0: 275 dataset.xmin = np.min(dataset.qx_data) 276 dataset.xmax = np.max(dataset.qx_data) 277 dataset.ymin = np.min(dataset.qy_data) 278 dataset.ymax = np.max(dataset.qx_data) 283 @staticmethod 284 def set_default_1d_units(data): 285 """ 286 Set the x and y axes to the default 1D units 287 :param data: 1D data set 288 :return: 289 """ 290 data.xaxis(r"\rm{Q}", '1/A') 291 data.yaxis(r"\rm{Intensity}", "1/cm") 292 return data 293 294 @staticmethod 295 def set_default_2d_units(data): 296 """ 297 Set the x and y axes to the default 2D units 298 :param data: 2D data set 299 :return: 300 """ 301 data.xaxis("\\rm{Q_{x}}", '1/A') 302 data.yaxis("\\rm{Q_{y}}", '1/A') 303 data.zaxis("\\rm{Intensity}", "1/cm") 304 return data 305 306 def convert_data_units(self, default_q_unit="1/A"): 307 """ 308 Converts al; data to the sasview default of units of A^{-1} for Q and 309 cm^{-1} for I. 310 :param default_q_unit: The default Q unit used by Sasview 311 """ 312 convert_q = True 313 new_output = [] 314 for data in self.output: 315 if data.isSesans: 316 new_output.append(data) 317 continue 318 try: 319 file_x_unit = data._xunit 320 data_conv_x = Converter(file_x_unit) 321 except KeyError: 322 logger.info("Unrecognized Q units in data file. No data " 323 "conversion attempted") 324 convert_q = False 325 try: 326 327 if isinstance(data, Data1D): 328 if convert_q: 329 data.x = data_conv_x(data.x, units=default_q_unit) 330 data._xunit = default_q_unit 331 data.x_unit = default_q_unit 332 if data.dx is not None: 333 data.dx = data_conv_x(data.dx, 334 units=default_q_unit) 335 if data.dxl is not None: 336 data.dxl = data_conv_x(data.dxl, 337 units=default_q_unit) 338 if data.dxw is not None: 339 data.dxw = data_conv_x(data.dxw, 340 units=default_q_unit) 341 elif isinstance(data, Data2D): 342 if convert_q: 343 data.qx_data = data_conv_x(data.qx_data, 344 units=default_q_unit) 345 if data.dqx_data is not None: 346 data.dqx_data = data_conv_x(data.dqx_data, 347 units=default_q_unit) 348 try: 349 file_y_unit = data._yunit 350 data_conv_y = Converter(file_y_unit) 351 data.qy_data = data_conv_y(data.qy_data, 352 units=default_q_unit) 353 if data.dqy_data is not None: 354 data.dqy_data = data_conv_y(data.dqy_data, 355 units=default_q_unit) 356 except KeyError: 357 logger.info("Unrecognized Qy units in data file. No" 358 " data conversion attempted") 359 except KeyError: 360 message = "Unable to convert Q units from {0} to 1/A." 361 message.format(default_q_unit) 362 data.errors.append(message) 363 new_output.append(data) 364 self.output = new_output 279 365 280 366 def format_unit(self, unit=None): … … 367 453 self.current_dataset.qy_data)) 368 454 if has_error_dy: 369 self.current_dataset.err_data = self.current_dataset.err_data[x != 0] 455 self.current_dataset.err_data = self.current_dataset.err_data[ 456 x != 0] 370 457 if has_error_dqx: 371 self.current_dataset.dqx_data = self.current_dataset.dqx_data[x != 0] 458 self.current_dataset.dqx_data = self.current_dataset.dqx_data[ 459 x != 0] 372 460 if has_error_dqy: 373 self.current_dataset.dqy_data = self.current_dataset.dqy_data[x != 0] 461 self.current_dataset.dqy_data = self.current_dataset.dqy_data[ 462 x != 0] 374 463 if has_mask: 375 464 self.current_dataset.mask = self.current_dataset.mask[x != 0] -
src/sas/sascalc/dataloader/loader.py
re090ba90 r8c9e65c 367 367 try: 368 368 return fn(path, data) 369 except Exception: 370 pass # give other loaders a chance to succeed 371 # If we get here it is because all loaders failed 372 raise # reraises last exception 369 except Exception as exc: 370 msg = "Saving file {} using the {} writer failed.\n".format( 371 path, type(fn).__name__) 372 msg += str(exc) 373 logger.exception(msg) # give other loaders a chance to succeed 373 374 374 375 -
src/sas/sascalc/dataloader/readers/abs_reader.py
rbd5c3b1 rd96744de 48 48 detector = Detector() 49 49 data_line = 0 50 x_index = 4 50 51 self.reset_data_list(len(lines)) 51 52 self.current_datainfo.detector.append(detector) … … 63 64 for line in lines: 64 65 # Information line 1 66 if line.find(".bt5") > 0: 67 x_index = 0 65 68 if is_info: 66 69 is_info = False … … 171 174 172 175 try: 173 _x = float(toks[ 4])176 _x = float(toks[x_index]) 174 177 _y = float(toks[1]) 175 178 _dy = float(toks[2]) … … 225 228 raise ValueError("ascii_reader: could not load file") 226 229 230 self.current_dataset = self.set_default_1d_units(self.current_dataset) 227 231 if data_conv_q is not None: 228 232 self.current_dataset.xaxis("\\rm{Q}", base_q_unit) 229 else:230 self.current_dataset.xaxis("\\rm{Q}", 'A^{-1}')231 233 if data_conv_i is not None: 232 234 self.current_dataset.yaxis("\\rm{Intensity}", base_i_unit) 233 else:234 self.current_dataset.yaxis("\\rm{Intensity}", "cm^{-1}")235 235 236 236 # Store loading process information -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r9e6aeaf r3bab401 157 157 158 158 self.remove_empty_q_values() 159 self.current_dataset.xaxis("\\rm{Q}", 'A^{-1}') 160 self.current_dataset.yaxis("\\rm{Intensity}", "cm^{-1}") 159 self.current_dataset = self.set_default_1d_units(self.current_dataset) 161 160 162 161 # Store loading process information -
src/sas/sascalc/dataloader/readers/associations.py
re090ba90 r8c9e65c 23 23 ".ses": "sesans_reader", 24 24 ".h5": "cansas_reader_HDF5", 25 ".nxs": "cansas_reader_HDF5", 25 26 ".txt": "ascii_reader", 26 27 ".dat": "red2d_reader", -
src/sas/sascalc/dataloader/readers/cansas_reader.py
re090ba90 r8c9e65c 812 812 node.append(point) 813 813 self.write_node(point, "Q", datainfo.x[i], 814 {'unit': datainfo. x_unit})814 {'unit': datainfo._xunit}) 815 815 if len(datainfo.y) >= i: 816 816 self.write_node(point, "I", datainfo.y[i], 817 {'unit': datainfo. y_unit})817 {'unit': datainfo._yunit}) 818 818 if datainfo.dy is not None and len(datainfo.dy) > i: 819 819 self.write_node(point, "Idev", datainfo.dy[i], 820 {'unit': datainfo. y_unit})820 {'unit': datainfo._yunit}) 821 821 if datainfo.dx is not None and len(datainfo.dx) > i: 822 822 self.write_node(point, "Qdev", datainfo.dx[i], 823 {'unit': datainfo. x_unit})823 {'unit': datainfo._xunit}) 824 824 if datainfo.dxw is not None and len(datainfo.dxw) > i: 825 825 self.write_node(point, "dQw", datainfo.dxw[i], 826 {'unit': datainfo. x_unit})826 {'unit': datainfo._xunit}) 827 827 if datainfo.dxl is not None and len(datainfo.dxl) > i: 828 828 self.write_node(point, "dQl", datainfo.dxl[i], 829 {'unit': datainfo. x_unit})829 {'unit': datainfo._xunit}) 830 830 if datainfo.isSesans: 831 831 sesans_attrib = {'x_axis': datainfo._xaxis, -
src/sas/sascalc/dataloader/readers/danse_reader.py
r2469df7 rfc51d06 180 180 detector.beam_center.y = center_y * pixel 181 181 182 183 self.current_dataset.xaxis("\\rm{Q_{x}}", 'A^{-1}') 184 self.current_dataset.yaxis("\\rm{Q_{y}}", 'A^{-1}') 185 self.current_dataset.zaxis("\\rm{Intensity}", "cm^{-1}") 186 182 self.current_dataset = self.set_default_2d_units(self.current_dataset) 187 183 self.current_dataset.x_bins = x_vals 188 184 self.current_dataset.y_bins = y_vals -
src/sas/sascalc/dataloader/readers/red2d_reader.py
rc8321cfc r058f6c3 317 317 318 318 # Units of axes 319 self.current_dataset.xaxis(r"\rm{Q_{x}}", 'A^{-1}') 320 self.current_dataset.yaxis(r"\rm{Q_{y}}", 'A^{-1}') 321 self.current_dataset.zaxis(r"\rm{Intensity}", "cm^{-1}") 319 self.current_dataset = self.set_default_2d_units(self.current_dataset) 322 320 323 321 # Store loading process information -
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/file_converter/nxcansas_writer.py
r574adc7 r109afbd 8 8 import os 9 9 10 from sas.sascalc.dataloader.readers.cansas_reader_HDF5 import Reader as Cansas2Reader10 from sas.sascalc.dataloader.readers.cansas_reader_HDF5 import Reader 11 11 from sas.sascalc.dataloader.data_info import Data1D, Data2D 12 12 13 class NXcanSASWriter( Cansas2Reader):13 class NXcanSASWriter(Reader): 14 14 """ 15 15 A class for writing in NXcanSAS data files. Any number of data sets may be … … 87 87 entry[names[2]].attrs['units'] = units 88 88 89 valid_data = all([is subclass(d.__class__, (Data1D, Data2D)) for d in dataset])89 valid_data = all([isinstance(d, (Data1D, Data2D)) for d in dataset]) 90 90 if not valid_data: 91 raise ValueError("All entries of dataset must be Data1D or Data2D objects") 91 raise ValueError("All entries of dataset must be Data1D or Data2D" 92 "objects") 92 93 93 94 # Get run name and number from first Data object … … 109 110 sasentry.attrs['version'] = '1.0' 110 111 111 i = 1 112 113 for data_obj in dataset: 114 data_entry = sasentry.create_group("sasdata{0:0=2d}".format(i)) 112 for i, data_obj in enumerate(dataset): 113 data_entry = sasentry.create_group("sasdata{0:0=2d}".format(i+1)) 115 114 data_entry.attrs['canSAS_class'] = 'SASdata' 116 115 if isinstance(data_obj, Data1D): … … 118 117 elif isinstance(data_obj, Data2D): 119 118 self._write_2d_data(data_obj, data_entry) 120 i += 1121 119 122 120 data_info = dataset[0] … … 148 146 sample_entry.create_dataset('details', data=details) 149 147 150 # Instrum ment metadata148 # Instrument metadata 151 149 instrument_entry = sasentry.create_group('sasinstrument') 152 150 instrument_entry.attrs['canSAS_class'] = 'SASinstrument' … … 176 174 units=data_info.source.beam_size_unit, write_fn=_write_h5_float) 177 175 178 179 176 # Collimation metadata 180 177 if len(data_info.collimation) > 0: 181 i = 1 182 for coll_info in data_info.collimation: 178 for i, coll_info in enumerate(data_info.collimation): 183 179 collimation_entry = instrument_entry.create_group( 184 'sascollimation{0:0=2d}'.format(i ))180 'sascollimation{0:0=2d}'.format(i + 1)) 185 181 collimation_entry.attrs['canSAS_class'] = 'SAScollimation' 186 182 if coll_info.length is not None: 187 183 _write_h5_float(collimation_entry, coll_info.length, 'SDD') 188 collimation_entry['SDD'].attrs['units'] = coll_info.length_unit 184 collimation_entry['SDD'].attrs['units'] =\ 185 coll_info.length_unit 189 186 if coll_info.name is not None: 190 187 collimation_entry['name'] = _h5_string(coll_info.name) 191 188 else: 192 # Create a blank one - at least 1 set of collimation metadata 193 # required by format 194 collimation_entry = instrument_entry.create_group('sascollimation01') 189 # Create a blank one - at least 1 collimation required by format 190 instrument_entry.create_group('sascollimation01') 195 191 196 192 # Detector metadata 197 193 if len(data_info.detector) > 0: 198 194 i = 1 199 for det_info in data_info.detector:195 for i, det_info in enumerate(data_info.detector): 200 196 detector_entry = instrument_entry.create_group( 201 'sasdetector{0:0=2d}'.format(i ))197 'sasdetector{0:0=2d}'.format(i + 1)) 202 198 detector_entry.attrs['canSAS_class'] = 'SASdetector' 203 199 if det_info.distance is not None: 204 200 _write_h5_float(detector_entry, det_info.distance, 'SDD') 205 detector_entry['SDD'].attrs['units'] = det_info.distance_unit 201 detector_entry['SDD'].attrs['units'] =\ 202 det_info.distance_unit 206 203 if det_info.name is not None: 207 204 detector_entry['name'] = _h5_string(det_info.name) … … 209 206 detector_entry['name'] = _h5_string('') 210 207 if det_info.slit_length is not None: 211 _write_h5_float(detector_entry, det_info.slit_length, 'slit_length') 212 detector_entry['slit_length'].attrs['units'] = det_info.slit_length_unit 208 _write_h5_float(detector_entry, det_info.slit_length, 209 'slit_length') 210 detector_entry['slit_length'].attrs['units'] =\ 211 det_info.slit_length_unit 213 212 _write_h5_vector(detector_entry, det_info.offset) 214 213 # NXcanSAS doesn't save information about pitch, only roll … … 224 223 names=['x_pixel_size', 'y_pixel_size'], 225 224 write_fn=_write_h5_float, units=det_info.pixel_size_unit) 226 227 i += 1228 225 else: 229 226 # Create a blank one - at least 1 detector required by format … … 231 228 detector_entry.attrs['canSAS_class'] = 'SASdetector' 232 229 detector_entry.attrs['name'] = '' 230 231 # Process meta data 232 for i, process in enumerate(data_info.process): 233 process_entry = sasentry.create_group('sasprocess{0:0=2d}'.format( 234 i + 1)) 235 process_entry.attrs['canSAS_class'] = 'SASprocess' 236 if process.name: 237 name = _h5_string(process.name) 238 process_entry.create_dataset('name', data=name) 239 if process.date: 240 date = _h5_string(process.date) 241 process_entry.create_dataset('date', data=date) 242 if process.description: 243 desc = _h5_string(process.description) 244 process_entry.create_dataset('description', data=desc) 245 for j, term in enumerate(process.term): 246 # Don't save empty terms 247 if term: 248 h5_term = _h5_string(term) 249 process_entry.create_dataset('term{0:0=2d}'.format( 250 j + 1), data=h5_term) 251 for j, note in enumerate(process.notes): 252 # Don't save empty notes 253 if note: 254 h5_note = _h5_string(note) 255 process_entry.create_dataset('note{0:0=2d}'.format( 256 j + 1), data=h5_note) 257 258 # Transmission Spectrum 259 for i, trans in enumerate(data_info.trans_spectrum): 260 trans_entry = sasentry.create_group( 261 'sastransmission_spectrum{0:0=2d}'.format(i + 1)) 262 trans_entry.attrs['canSAS_class'] = 'SAStransmission_spectrum' 263 trans_entry.attrs['signal'] = 'T' 264 trans_entry.attrs['T_axes'] = 'T' 265 trans_entry.attrs['name'] = trans.name 266 if trans.timestamp is not '': 267 trans_entry.attrs['timestamp'] = trans.timestamp 268 transmission = trans_entry.create_dataset('T', 269 data=trans.transmission) 270 transmission.attrs['unertainties'] = 'Tdev' 271 trans_entry.create_dataset('Tdev', 272 data=trans.transmission_deviation) 273 trans_entry.create_dataset('lambda', data=trans.wavelength) 233 274 234 275 note_entry = sasentry.create_group('sasnote'.format(i)) … … 254 295 data_entry.attrs['signal'] = 'I' 255 296 data_entry.attrs['I_axes'] = 'Q' 256 data_entry.attrs['I_uncertainties'] = 'Idev' 257 data_entry.attrs['Q_indicies'] = 0 258 259 dI = data_obj.dy 260 if dI is None: 261 dI = np.zeros((data_obj.y.shape)) 262 263 data_entry.create_dataset('Q', data=data_obj.x) 264 data_entry.create_dataset('I', data=data_obj.y) 265 data_entry.create_dataset('Idev', data=dI) 297 data_entry.attrs['Q_indices'] = [0] 298 q_entry = data_entry.create_dataset('Q', data=data_obj.x) 299 q_entry.attrs['units'] = data_obj.x_unit 300 i_entry = data_entry.create_dataset('I', data=data_obj.y) 301 i_entry.attrs['units'] = data_obj.y_unit 302 if data_obj.dy is not None: 303 i_entry.attrs['uncertainties'] = 'Idev' 304 i_dev_entry = data_entry.create_dataset('Idev', data=data_obj.dy) 305 i_dev_entry.attrs['units'] = data_obj.y_unit 306 if data_obj.dx is not None: 307 q_entry.attrs['resolutions'] = 'dQ' 308 dq_entry = data_entry.create_dataset('dQ', data=data_obj.dx) 309 dq_entry.attrs['units'] = data_obj.x_unit 310 elif data_obj.dxl is not None: 311 q_entry.attrs['resolutions'] = ['dQl','dQw'] 312 dql_entry = data_entry.create_dataset('dQl', data=data_obj.dxl) 313 dql_entry.attrs['units'] = data_obj.x_unit 314 dqw_entry = data_entry.create_dataset('dQw', data=data_obj.dxw) 315 dqw_entry.attrs['units'] = data_obj.x_unit 266 316 267 317 def _write_2d_data(self, data, data_entry): … … 273 323 """ 274 324 data_entry.attrs['signal'] = 'I' 275 data_entry.attrs['I_axes'] = 'Q,Q' 276 data_entry.attrs['I_uncertainties'] = 'Idev' 277 data_entry.attrs['Q_indicies'] = [0,1] 325 data_entry.attrs['I_axes'] = 'Qx,Qy' 326 data_entry.attrs['Q_indices'] = [0,1] 278 327 279 328 (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins)) 280 329 281 if n_rows == 0 and n_cols == 0:330 if (n_rows == 0 and n_cols == 0) or (n_cols*n_rows != data.data.size): 282 331 # Calculate rows and columns, assuming detector is square 283 332 # Same logic as used in PlotPanel.py _get_bins … … 288 337 raise ValueError("Unable to calculate dimensions of 2D data") 289 338 290 I = np.reshape(data.data, (n_rows, n_cols)) 291 dI = np.zeros((n_rows, n_cols)) 292 if not all(data.err_data == [None]): 293 dI = np.reshape(data.err_data, (n_rows, n_cols)) 294 qx = np.reshape(data.qx_data, (n_rows, n_cols)) 339 intensity = np.reshape(data.data, (n_rows, n_cols)) 340 qx = np.reshape(data.qx_data, (n_rows, n_cols)) 295 341 qy = np.reshape(data.qy_data, (n_rows, n_cols)) 296 342 297 I_entry = data_entry.create_dataset('I', data=I) 298 I_entry.attrs['units'] = data.I_unit 299 Qx_entry = data_entry.create_dataset('Qx', data=qx) 300 Qx_entry.attrs['units'] = data.Q_unit 301 Qy_entry = data_entry.create_dataset('Qy', data=qy) 302 Qy_entry.attrs['units'] = data.Q_unit 303 Idev_entry = data_entry.create_dataset('Idev', data=dI) 304 Idev_entry.attrs['units'] = data.I_unit 343 i_entry = data_entry.create_dataset('I', data=intensity) 344 i_entry.attrs['units'] = data.I_unit 345 qx_entry = data_entry.create_dataset('Qx', data=qx) 346 qx_entry.attrs['units'] = data.Q_unit 347 qy_entry = data_entry.create_dataset('Qy', data=qy) 348 qy_entry.attrs['units'] = data.Q_unit 349 if (data.err_data is not None 350 and not all(v is None for v in data.err_data)): 351 d_i = np.reshape(data.err_data, (n_rows, n_cols)) 352 i_entry.attrs['uncertainties'] = 'Idev' 353 i_dev_entry = data_entry.create_dataset('Idev', data=d_i) 354 i_dev_entry.attrs['units'] = data.I_unit 355 if (data.dqx_data is not None 356 and not all(v is None for v in data.dqx_data)): 357 qx_entry.attrs['resolutions'] = 'dQx' 358 dqx_entry = data_entry.create_dataset('dQx', data=data.dqx_data) 359 dqx_entry.attrs['units'] = data.Q_unit 360 if (data.dqy_data is not None 361 and not all(v is None for v in data.dqy_data)): 362 qy_entry.attrs['resolutions'] = 'dQy' 363 dqy_entry = data_entry.create_dataset('dQy', data=data.dqy_data) 364 dqy_entry.attrs['units'] = data.Q_unit 365 if data.mask is not None and not all(v is None for v in data.mask): 366 data_entry.attrs['mask'] = "mask" 367 mask = np.invert(np.asarray(data.mask, dtype=bool)) 368 data_entry.create_dataset('mask', data=mask) -
src/sas/sascalc/pr/c_extensions/Cinvertor.c
ra52f32f r7ba6470 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 16 // Vector binding glue 17 #if (PY_VERSION_HEX > 0x03000000) && !defined(Py_LIMITED_API) 18 // Assuming that a view into a writable vector points to a 19 // non-changing pointer for the duration of the C call, capture 20 // the view pointer and immediately free the view. 21 #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \ 22 Py_buffer VEC_view; \ 23 int VEC_err = PyObject_GetBuffer(VEC_obj, &VEC_view, PyBUF_WRITABLE|PyBUF_FORMAT); \ 24 if (VEC_err < 0 || sizeof(*VEC_buf) != VEC_view.itemsize) return NULL; \ 25 VEC_buf = (typeof(VEC_buf))VEC_view.buf; \ 26 VEC_len = VEC_view.len/sizeof(*VEC_buf); \ 27 PyBuffer_Release(&VEC_view); \ 28 } while (0) 29 #else 30 #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \ 31 int VEC_err = PyObject_AsWriteBuffer(VEC_obj, (void **)(&VEC_buf), &VEC_len); \ 32 if (VEC_err < 0) return NULL; \ 33 VEC_len /= sizeof(*VEC_buf); \ 34 } while (0) 35 #endif 36 14 37 #include "invertor.h" 15 16 38 17 39 /// Error object for raised exceptions 18 40 PyObject * CinvertorError; 19 20 #define INVECTOR(obj,buf,len) \21 do { \22 int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \23 if (err < 0) return NULL; \24 len /= sizeof(*buf); \25 } while (0)26 27 #define OUTVECTOR(obj,buf,len) \28 do { \29 int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \30 if (err < 0) return NULL; \31 len /= sizeof(*buf); \32 } while (0)33 34 41 35 42 // Class definition … … 99 106 100 107 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 101 OUTVECTOR(data_obj,data,ndata);108 VECTOR(data_obj,data,ndata); 102 109 103 110 free(self->params.x); … … 131 138 132 139 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 133 OUTVECTOR(data_obj, data, ndata);140 VECTOR(data_obj, data, ndata); 134 141 135 142 // Check that the input array is large enough … … 164 171 165 172 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 166 OUTVECTOR(data_obj,data,ndata);173 VECTOR(data_obj,data,ndata); 167 174 168 175 free(self->params.y); … … 196 203 197 204 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 198 OUTVECTOR(data_obj, data, ndata);205 VECTOR(data_obj, data, ndata); 199 206 200 207 // Check that the input array is large enough … … 229 236 230 237 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 231 OUTVECTOR(data_obj,data,ndata);238 VECTOR(data_obj,data,ndata); 232 239 233 240 free(self->params.err); … … 261 268 262 269 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 263 OUTVECTOR(data_obj, data, ndata);270 VECTOR(data_obj, data, ndata); 264 271 265 272 // Check that the input array is large enough … … 517 524 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 518 525 519 OUTVECTOR(data_obj,pars,npars);526 VECTOR(data_obj,pars,npars); 520 527 521 528 // PyList of residuals … … 568 575 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 569 576 570 OUTVECTOR(data_obj,pars,npars);577 VECTOR(data_obj,pars,npars); 571 578 572 579 // Should create this list only once and refill it … … 609 616 610 617 if (!PyArg_ParseTuple(args, "Od", &data_obj, &q)) return NULL; 611 OUTVECTOR(data_obj,pars,npars);618 VECTOR(data_obj,pars,npars); 612 619 613 620 iq_value = iq(pars, self->params.d_max, (int)npars, q); … … 634 641 635 642 if (!PyArg_ParseTuple(args, "Od", &data_obj, &q)) return NULL; 636 OUTVECTOR(data_obj,pars,npars);643 VECTOR(data_obj,pars,npars); 637 644 638 645 iq_value = iq_smeared(pars, self->params.d_max, (int)npars, … … 659 666 660 667 if (!PyArg_ParseTuple(args, "Od", &data_obj, &r)) return NULL; 661 OUTVECTOR(data_obj,pars,npars);668 VECTOR(data_obj,pars,npars); 662 669 663 670 pr_value = pr(pars, self->params.d_max, (int)npars, r); … … 686 693 687 694 if (!PyArg_ParseTuple(args, "OOd", &data_obj, &err_obj, &r)) return NULL; 688 OUTVECTOR(data_obj,pars,npars);695 VECTOR(data_obj,pars,npars); 689 696 690 697 if (err_obj == Py_None) { … … 692 699 pr_err_value = 0.0; 693 700 } else { 694 OUTVECTOR(err_obj,pars_err,npars2);701 VECTOR(err_obj,pars_err,npars2); 695 702 pr_err(pars, pars_err, self->params.d_max, (int)npars, r, &pr_value, &pr_err_value); 696 703 } … … 726 733 727 734 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 728 OUTVECTOR(data_obj,pars,npars);735 VECTOR(data_obj,pars,npars); 729 736 730 737 oscill = reg_term(pars, self->params.d_max, (int)npars, 100); … … 747 754 748 755 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 749 OUTVECTOR(data_obj,pars,npars);756 VECTOR(data_obj,pars,npars); 750 757 751 758 count = npeaks(pars, self->params.d_max, (int)npars, 100); … … 768 775 769 776 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 770 OUTVECTOR(data_obj,pars,npars);777 VECTOR(data_obj,pars,npars); 771 778 772 779 fraction = positive_integral(pars, self->params.d_max, (int)npars, 100); … … 792 799 793 800 if (!PyArg_ParseTuple(args, "OO", &data_obj, &err_obj)) return NULL; 794 OUTVECTOR(data_obj,pars,npars);795 OUTVECTOR(err_obj,pars_err,npars2);801 VECTOR(data_obj,pars,npars); 802 VECTOR(err_obj,pars_err,npars2); 796 803 797 804 fraction = positive_errors(pars, pars_err, self->params.d_max, (int)npars, 51); … … 813 820 814 821 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 815 OUTVECTOR(data_obj,pars,npars);822 VECTOR(data_obj,pars,npars); 816 823 817 824 value = rg(pars, self->params.d_max, (int)npars, 101); … … 833 840 834 841 if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL; 835 OUTVECTOR(data_obj,pars,npars);842 VECTOR(data_obj,pars,npars); 836 843 837 844 value = 4.0*acos(-1.0)*int_pr(pars, self->params.d_max, (int)npars, 101); … … 874 881 875 882 if (!PyArg_ParseTuple(args, "iiOO", &nfunc, &nr, &a_obj, &b_obj)) return NULL; 876 OUTVECTOR(a_obj,a,n_a);877 OUTVECTOR(b_obj,b,n_b);883 VECTOR(a_obj,a,n_a); 884 VECTOR(b_obj,b,n_b); 878 885 879 886 assert(n_b>=nfunc); … … 947 954 948 955 if (!PyArg_ParseTuple(args, "iiOO", &nfunc, &nr, &a_obj, &cov_obj)) return NULL; 949 OUTVECTOR(a_obj,a,n_a);950 OUTVECTOR(cov_obj,inv_cov,n_cov);956 VECTOR(a_obj,a,n_a); 957 VECTOR(cov_obj,inv_cov,n_cov); 951 958 952 959 assert(n_cov>=nfunc*nfunc); … … 981 988 982 989 if (!PyArg_ParseTuple(args, "iiO", &nfunc, &nr, &a_obj)) return NULL; 983 OUTVECTOR(a_obj,a,n_a);990 VECTOR(a_obj,a,n_a); 984 991 985 992 assert(n_a>=nfunc*(nr+self->params.npoints)); … … 1121 1128 1122 1129 #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_inversion1130 #define MODULE_NAME "_pr_inversion" 1131 #define MODULE_INIT2 init_pr_inversion 1132 #define MODULE_INIT3 PyInit__pr_inversion 1126 1133 #define MODULE_METHODS module_methods 1127 1134 -
src/sas/sascalc/pr/fit/BumpsFitting.py
r9a5097c r3e6829d 2 2 BumpsFitting module runs the bumps optimizer. 3 3 """ 4 from __future__ import division 5 4 6 import os 5 7 from datetime import timedelta, datetime … … 34 36 class Progress(object): 35 37 def __init__(self, history, max_step, pars, dof): 36 remaining_time = int(history.time[0]*( float(max_step)/history.step[0]-1))38 remaining_time = int(history.time[0]*(max_step/history.step[0]-1)) 37 39 # Depending on the time remaining, either display the expected 38 40 # time of completion, or the amount of time remaining. Use precision -
src/sas/sascalc/pr/fit/Loader.py
r574adc7 r57e48ca 1 """ 2 class Loader to load any kind of file 3 """ 4 1 5 from __future__ import print_function 2 6 3 # class Loader to load any king of file4 #import wx5 #import string6 7 import numpy as np 7 8 -
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: -
src/sas/sascalc/pr/num_term.py
re090ba90 r8c9e65c 1 from __future__ import print_function 1 from __future__ import print_function, division 2 2 3 3 import math … … 51 51 osc = self.sort_osc() 52 52 dv = len(osc) 53 med = float(dv) / 2.053 med = 0.5*dv 54 54 odd = self.is_odd(dv) 55 55 medi = 0 … … 140 140 nts = self.compare_err() 141 141 div = len(nts) 142 tem = float(div) / 2.0142 tem = 0.5*div 143 143 if self.is_odd(div): 144 144 nt = nts[int(tem)] -
src/sas/sasgui/guiframe/gui_manager.py
r8ac05a5 rdcd6efd 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 62 63 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 63 64 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 64 if not WELCOME_PANEL_ON: 65 WELCOME_PANEL_SHOW = False 65 66 def custom_value(name, default=None): 67 """ 68 Fetch a config value from custom_config. Fallback to config, and then 69 to default if it doesn't exist in config. 70 """ 71 default = getattr(config, name, default) 72 return getattr(custom_config, name, default) 73 74 # Custom config values in the order they appear. 75 DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1) 76 CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False) 77 FIXED_PANEL = custom_value('FIXED_PANEL', True) 78 PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1) 79 DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True) 80 GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1) 81 GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1) 82 CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1) 83 CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1) 84 open_folder = custom_value('DEFAULT_OPEN_FOLDER', None) 85 if open_folder is not None and os.path.isdir(open_folder): 86 DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 66 87 else: 67 WELCOME_PANEL_SHOW = True68 try:69 DATALOADER_SHOW = custom_config.DATALOADER_SHOW70 TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW71 FIXED_PANEL = custom_config.FIXED_PANEL72 if WELCOME_PANEL_ON:73 WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW74 PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH75 DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH76 GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH77 GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT78 CONTROL_WIDTH = custom_config.CONTROL_WIDTH79 CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT80 DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE81 CLEANUP_PLOT = custom_config.CLEANUP_PLOT82 # custom open_path83 open_folder = custom_config.DEFAULT_OPEN_FOLDER84 if open_folder is not None and os.path.isdir(open_folder):85 DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)86 else:87 DEFAULT_OPEN_FOLDER = get_app_dir()88 SAS_OPENCL = custom_config.SAS_OPENCL89 except:90 DATALOADER_SHOW = True91 TOOLBAR_SHOW = True92 FIXED_PANEL = True93 WELCOME_PANEL_SHOW = False94 PLOPANEL_WIDTH = config.PLOPANEL_WIDTH95 DATAPANEL_WIDTH = config.DATAPANEL_WIDTH96 GUIFRAME_WIDTH = config.GUIFRAME_WIDTH97 GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT98 CONTROL_WIDTH = -199 CONTROL_HEIGHT = -1100 DEFAULT_PERSPECTIVE = None101 CLEANUP_PLOT = False102 88 DEFAULT_OPEN_FOLDER = get_app_dir() 103 DEFAULT_OPEN_FOLDER = PATH_APP 104 SAS_OPENCL = None 89 WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False) 90 if WELCOME_PANEL_ON else False) 91 TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True) 92 DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting') 93 SAS_OPENCL = custom_value('SAS_OPENCL', 'None') 94 105 95 DEFAULT_STYLE = config.DEFAULT_STYLE 106 107 96 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 108 97 OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU … … 2170 2159 # original 2.x tutorial. 2171 2160 # Code below, implemented from 4.2.0, redirects 2172 # action to the Tutorials page of the help 2161 # action to the Tutorials page of the help 2173 2162 # documentation to give access to all available 2174 2163 # tutorials … … 2419 2408 default_name = fname 2420 2409 wildcard = "Text files (*.txt)|*.txt|"\ 2421 "CanSAS 1D files(*.xml)|*.xml" 2422 path = None 2410 "CanSAS 1D files (*.xml)|*.xml|"\ 2411 "NXcanSAS files (*.h5)|*.h5|" 2412 options = [".txt", ".xml",".h5"] 2423 2413 dlg = wx.FileDialog(self, "Choose a file", 2424 2414 self._default_save_location, … … 2430 2420 # This is MAC Fix 2431 2421 ext_num = dlg.GetFilterIndex() 2432 if ext_num == 0: 2433 ext_format = '.txt' 2434 else: 2435 ext_format = '.xml' 2422 2423 ext_format = options[ext_num] 2436 2424 path = os.path.splitext(path)[0] + ext_format 2437 2425 mypath = os.path.basename(path) 2438 2439 # Instantiate a loader 2440 loader = Loader() 2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2426 fName = os.path.splitext(path)[0] + ext_format 2427 2428 if os.path.splitext(mypath)[1].lower() == options[0]: 2443 2429 # Make sure the ext included in the file name 2444 2430 # especially on MAC 2445 fName = os.path.splitext(path)[0] + ext_format2446 2431 self._onsaveTXT(data, fName) 2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2432 elif os.path.splitext(mypath)[1].lower() == options[1]: 2449 2433 # Make sure the ext included in the file name 2450 2434 # especially on MAC 2451 fName = os.path.splitext(path)[0] + ext_format 2435 # Instantiate a loader 2436 loader = Loader() 2452 2437 loader.save(fName, data, ext_format) 2438 elif os.path.splitext(mypath)[1].lower() == options[2]: 2439 nxcansaswriter = NXcanSASWriter() 2440 nxcansaswriter.write([data], fName) 2453 2441 try: 2454 2442 self._default_save_location = os.path.dirname(path) … … 2477 2465 if has_errors: 2478 2466 if data.dx is not None and data.dx != []: 2479 out.write("<X> <Y> <dY><dX>\n")2467 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2480 2468 else: 2481 out.write("<X> <Y><dY>\n")2469 out.write("<X>\t<Y>\t<dY>\n") 2482 2470 else: 2483 out.write("<X> 2471 out.write("<X>\t<Y>\n") 2484 2472 2485 2473 for i in range(len(data.x)): … … 2525 2513 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2526 2514 text += '\nData Points:\n' 2527 x_st = "X" 2515 text += "<index> \t<X> \t<Y> \t<dY> " 2516 text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 2517 data.dxw is not None) else "\t<dX>\n" 2528 2518 for index in range(len(data.x)): 2529 2519 if data.dy is not None and len(data.dy) > index: … … 2536 2526 dx_val = 0.0 2537 2527 if data.dxl is not None and len(data.dxl) > index: 2538 if index == 0:2539 x_st = "Xl"2540 2528 dx_val = data.dxl[index] 2541 elif data.dxw is not None and len(data.dxw) > index: 2542 if index == 0: 2543 x_st = "Xw" 2544 dx_val = data.dxw[index] 2545 2546 if index == 0: 2547 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2529 if data.dxw is not None and len(data.dxw) > index: 2530 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2531 2548 2532 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2549 2533 data.x[index], … … 2562 2546 """ 2563 2547 default_name = fname 2564 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2548 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2549 "NXcanSAS files (*.h5)|*.h5|" 2565 2550 dlg = wx.FileDialog(self, "Choose a file", 2566 2551 self._default_save_location, … … 2574 2559 if ext_num == 0: 2575 2560 ext_format = '.dat' 2561 elif ext_num == 1: 2562 ext_format = '.h5' 2576 2563 else: 2577 2564 ext_format = '' … … 2581 2568 # Instantiate a loader 2582 2569 loader = Loader() 2583 2584 ext_format = ".dat" 2585 if os.path.splitext(mypath)[1].lower() == ext_format: 2570 ext = os.path.splitext(mypath)[1].lower() 2571 if ext == '.dat': 2586 2572 # Make sure the ext included in the file name 2587 2573 # especially on MAC 2588 2574 fileName = os.path.splitext(path)[0] + ext_format 2589 2575 loader.save(fileName, data, ext_format) 2576 elif ext == '.h5': 2577 # Make sure the ext included in the file name 2578 # especially on MAC 2579 fileName = os.path.splitext(path)[0] + ext_format 2580 nxcansaswriter = NXcanSASWriter() 2581 nxcansaswriter.write([data], fileName) 2590 2582 try: 2591 2583 self._default_save_location = os.path.dirname(path) -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r9c7e2b8 r5218180 205 205 except NoKnownLoaderException as e: 206 206 exception_occurred = True 207 error_message = "Loading data failed! " + e.message207 error_message = "Loading data failed!\n" + e.message 208 208 file_errors[basename] = [error_message] 209 209 except Exception as e: … … 224 224 for message in error_array: 225 225 error_message += message + "\n" 226 error_message = error_message[:-1] 226 227 self.load_complete(output=output, 227 228 message=error_message, … … 231 232 self.load_complete(output=output, message="Loading data complete!", 232 233 info="info") 233 else:234 self.load_complete(output=None, message=error_message, info="error")235 234 236 235 def load_update(self, message="", info="warning"): -
src/sas/sasgui/perspectives/calculator/model_editor.py
r9bf40e7 r1752f38 965 965 out_f.write(' """Absolute scattering"""\n') 966 966 if "scipy." in func_str: 967 out_f.write(' import scipy ')967 out_f.write(' import scipy\n') 968 968 if "numpy." in func_str: 969 out_f.write(' import numpy ')969 out_f.write(' import numpy\n') 970 970 if "np." in func_str: 971 out_f.write(' import numpy as np ')971 out_f.write(' import numpy as np\n') 972 972 for func_line in func_str.split('\n'): 973 973 out_f.write('%s%s\n' % (' ', func_line)) -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r5652efc ref74a8b 277 277 self._transformed_data = transforms 278 278 (transform1, transform3, idf) = transforms 279 plot_x = transform1.x[transform1.x <= 200]280 plot_y = transform1.y[transform1.x <= 200]279 plot_x = transform1.x[transform1.x <= 1000] 280 plot_y = transform1.y[transform1.x <= 1000] 281 281 self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL1) 282 # No need to shorten gamma3 as it's only calculated up to x= 200282 # No need to shorten gamma3 as it's only calculated up to x=1000 283 283 self._manager.show_data(transform3, TRANSFORM_LABEL3) 284 284 285 plot_x = idf.x[idf.x <= 200]286 plot_y = idf.y[idf.x <= 200]285 plot_x = idf.x[idf.x <= 1000] 286 plot_y = idf.y[idf.x <= 1000] 287 287 self._manager.show_data(Data1D(plot_x, plot_y), IDF_LABEL) 288 288 -
src/sas/sasgui/perspectives/corfunc/media/corfunc_help.rst
r490f790 r4d06668 30 30 of the profile provides measures of the layer thickness, and the area under 31 31 the profile is related to the amount of material that is adsorbed. 32 33 .. note:: 34 These transforms assume that the data has been measured on a pinhole- 35 collimated instrument or, if not, that the data has been Lorentz- 36 corrected beforehand. 32 37 33 38 Both analyses are performed in 3 stages: -
src/sas/sasgui/perspectives/fitting/fitpage.py
rba1c145 rca4f40d 13 13 import time 14 14 import traceback 15 import logging 15 16 16 17 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 17 18 18 19 from sas.sascalc.fit.qsmearing import smear_selection 20 from sas.sascalc.dataloader.data_info import Data1D, Data2D 19 21 20 22 from sas.sasgui.guiframe.events import StatusEvent, NewPlotEvent, \ … … 28 30 PageInfoEvent 29 31 from .basepage import ModelTextCtrl 32 33 logger = logging.getLogger(__name__) 30 34 31 35 (Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent() … … 184 188 :return: True or False 185 189 """ 186 if self.data.__class__.__name__ == "Data2D" or \ 187 self.enable2D: 190 if isinstance(self.data, Data2D) or self.enable2D: 188 191 return True 189 192 return False … … 199 202 200 203 # Check if data is 2D 201 if self.data.__class__.__name__ == "Data2D" or \ 202 self.enable2D: 204 if isinstance(self.data, Data2D) or self.enable2D: 203 205 is_2d_data = True 204 206 … … 213 215 smear_message_new_psmear = \ 214 216 "Please enter a fixed percentage to be applied to all Q values..." 215 smear_message_2d_x_title = "<dQp>[1/A]:" 216 smear_message_2d_y_title = "<dQs>[1/A]:" 217 smear_message_pinhole_percent_title = "dQ[%]:" 217 smear_message_2d_x_title = "<dQ/Q>_r[%]:" 218 smear_message_2d_y_title = "<dQ/Q>_phi[%]:" 219 smear_message_pinhole_percent_min_title = "[dQ/Q]min(%):" 220 smear_message_pinhole_percent_max_title = "[dQ/Q]max(%):" 221 smear_message_pinhole_percent_title = "dQ/Q(%):" 218 222 smear_message_slit_height_title = "Slit height[1/A]:" 219 223 smear_message_slit_width_title = "Slit width[1/A]:" … … 418 422 smear_message_2d_x_title, style=wx.ALIGN_LEFT) 419 423 self.smear_description_2d_x.SetToolTipString( 420 " dQ p(parallel) in q_r direction.")424 " dQ_r q_r in polar coordinates.") 421 425 self.smear_description_2d_y = wx.StaticText(self, wx.ID_ANY, 422 426 smear_message_2d_y_title, style=wx.ALIGN_LEFT) 423 427 self.smear_description_2d_y.SetToolTipString( 424 " dQs(perpendicular) in q_phi direction.") 428 " dQ_phi q_phi in polar coordinates.") 429 self.smear_description_pin_percent_min = wx.StaticText(self, wx.ID_ANY, 430 smear_message_pinhole_percent_min_title, 431 style=wx.ALIGN_LEFT) 432 self.smear_description_pin_percent_max = wx.StaticText(self, wx.ID_ANY, 433 smear_message_pinhole_percent_max_title, 434 style=wx.ALIGN_LEFT) 425 435 self.smear_description_pin_percent = wx.StaticText(self, wx.ID_ANY, 426 436 smear_message_pinhole_percent_title, … … 449 459 self.sizer_new_smear.Add((15, -1)) 450 460 self.sizer_new_smear.Add(self.smear_description_2d_x, 0, wx.CENTER, 10) 461 self.sizer_new_smear.Add(self.smear_description_pin_percent_min, 462 0, wx.CENTER, 10) 463 self.sizer_new_smear.Add(self.smear_description_pin_percent, 464 0, wx.CENTER, 10) 451 465 self.sizer_new_smear.Add(self.smear_description_slit_height, 452 466 0, wx.CENTER, 10) 453 467 468 self.sizer_new_smear.Add(self.smear_pinhole_percent, 0, wx.CENTER, 10) 454 469 self.sizer_new_smear.Add(self.smear_slit_height, 0, wx.CENTER, 10) 455 470 self.sizer_new_smear.Add(self.smear_data_left, 0, wx.CENTER, 10) … … 457 472 self.sizer_new_smear.Add(self.smear_description_2d_y, 458 473 0, wx.CENTER, 10) 459 self.sizer_new_smear.Add(self.smear_description_pin_percent ,474 self.sizer_new_smear.Add(self.smear_description_pin_percent_max, 460 475 0, wx.CENTER, 10) 461 476 self.sizer_new_smear.Add(self.smear_description_slit_width, 462 477 0, wx.CENTER, 10) 463 478 464 self.sizer_new_smear.Add(self.smear_pinhole_percent, 0, wx.CENTER, 10)465 479 self.sizer_new_smear.Add(self.smear_slit_width, 0, wx.CENTER, 10) 466 480 self.sizer_new_smear.Add(self.smear_data_right, 0, wx.CENTER, 10) … … 503 517 504 518 # check if it is 2D data 505 if self.data.__class__.__name__ == "Data2D"or self.enable2D:519 if isinstance(self.data, Data2D) or self.enable2D: 506 520 is_2d_data = True 507 521 … … 806 820 self.sizer4_4.Add(cb, (iy, ix), (1, 1), 807 821 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 808 if self.data.__class__.__name__ == "Data2D" or \ 809 self.enable2D: 822 if isinstance(self.data, Data2D) or self.enable2D: 810 823 cb.Show(True) 811 824 elif cb.IsShown(): … … 819 832 ctl1.SetToolTipString(poly_tip) 820 833 ctl1.SetValue(str(format_number(value, True))) 821 if self.data.__class__.__name__ == "Data2D" or \ 822 self.enable2D: 834 if isinstance(self.data, Data2D) or self.enable2D: 823 835 if first_orient: 824 836 values.SetLabel('PD[ratio], Sig[deg]') … … 854 866 855 867 ctl2.Hide() 856 if self.data.__class__.__name__ == "Data2D" or \ 857 self.enable2D: 868 if isinstance(self.data, Data2D) or self.enable2D: 858 869 if self.is_mac: 859 870 text2.Show(True) … … 880 891 ctl4.Hide() 881 892 882 if self.data.__class__.__name__ == "Data2D" or \ 883 self.enable2D: 893 if isinstance(self.data, Data2D) or self.enable2D: 884 894 ctl3.Show(True) 885 895 ctl4.Show(True) … … 893 903 894 904 Tctl.SetValue(str(format_number(value))) 895 if self.data.__class__.__name__ == "Data2D" or \ 896 self.enable2D: 905 if isinstance(self.data, Data2D) or self.enable2D: 897 906 Tctl.Show(True) 898 907 else: … … 913 922 914 923 Tct2.SetValue(str(format_number(value))) 915 if self.data.__class__.__name__ == "Data2D" or \ 916 self.enable2D: 924 if isinstance(self.data, Data2D) or self.enable2D: 917 925 Tct2.Show(True) 918 926 else: … … 941 949 text2, ctl2, ctl3, ctl4, disp_box]) 942 950 943 if self.data.__class__.__name__ == "Data2D" or \ 944 self.enable2D: 951 if isinstance(self.data, Data2D) or self.enable2D: 945 952 disp_box.Show(True) 946 953 else: … … 1327 1334 flag1 = self.update_pinhole_smear() 1328 1335 flag = flag or flag1 1329 elif self.data.__class__.__name__ != "Data2D" and \ 1330 not self.enable2D: 1336 elif not isinstance(self.data, Data2D) and not self.enable2D: 1331 1337 enable_smearer = not self.disable_smearer.GetValue() 1332 1338 self._manager.set_smearer(smearer=temp_smearer, … … 1401 1407 if event is not None: 1402 1408 event.Skip() 1403 if self.data.__class__.__name__ == "Data2D":1409 if isinstance(self.data, Data2D): 1404 1410 return 1405 1411 is_click = event.LeftDown() … … 1419 1425 if event is not None: 1420 1426 event.Skip() 1421 if self.data.__class__.__name__ == "Data2D":1427 if isinstance(self.data, Data2D): 1422 1428 return 1423 1429 act_ctrl = event.GetEventObject() … … 1435 1441 """ 1436 1442 event.Skip() 1437 if self.data.__class__.__name__ == "Data2D":1443 if isinstance(self.data, Data2D): 1438 1444 return 1439 1445 ctrl = event.GetEventObject() … … 1496 1502 # Check if # of points for theory model are valid(>0). 1497 1503 # check for 2d 1498 if self.data.__class__.__name__ == "Data2D" or \ 1499 self.enable2D: 1504 if isinstance(self.data, Data2D) or self.enable2D: 1500 1505 # set mask 1501 1506 radius = np.sqrt(self.data.qx_data * self.data.qx_data + … … 1549 1554 if item[0].IsShown(): 1550 1555 # Skip the angle parameters if 1D data 1551 if self.data.__class__.__name__ != "Data2D" and \ 1552 not self.enable2D: 1556 if not isinstance(self.data, Data2D) and not self.enable2D: 1553 1557 if item in self.orientation_params: 1554 1558 continue … … 1568 1572 if item[0].IsShown(): 1569 1573 # Skip the angle parameters if 1D data 1570 if self.data.__class__.__name__ != "Data2D" and \ 1571 not self.enable2D: 1574 if not isinstance(self.data, Data2D) and not self.enable2D: 1572 1575 if item in self.orientation_params: 1573 1576 continue … … 1601 1604 1602 1605 :return: self.smear_type, self.dq_l and self.dq_r, 1603 respectively the type of the smear, dq_min and 1604 dq_max for pinhole smear data 1605 while dxl and dxw for slit smear 1606 """ 1607 # default 1606 respectively the type of the smear, The average <dq/q> radial(p) 1607 and <dq/q> theta (s)s for 2D pinhole resolution in % (slit is not 1608 currently supported in 2D), (dq/q)_min and (dq/q)_max for 1D pinhole 1609 smeared data, again in %, and dxl and/or dxw for slit smeared data 1610 given in 1/A and assumed constant. 1611 """ 1612 # set up defaults 1608 1613 self.smear_type = None 1609 1614 self.dq_l = None 1610 1615 self.dq_r = None 1611 1616 data = self.data 1617 #sanity check - this should only be called if data exits 1612 1618 if self.data is None: 1613 1619 return 1614 elif self.data.__class__.__name__ == "Data2D" or \1615 self.enable2D:1616 if data.dqx_data is None or data.dqy_data is None:1617 return1618 elif self.current_smearer is not None \1619 and data.dqx_data.any() != 0\1620 and data.dqx_data.any() != 0:1620 #First check if data is 2D 1621 #If so check that data set has smearing info and that none are zero. 1622 #Otherwise no smearing can be applied using smear from data (a Gaussian 1623 #width of zero will cause a divide by zero error) 1624 if isinstance(self.data, Data2D): 1625 if data.dqx_data is not None and data.dqy_data is not None \ 1626 and data.dqx_data.all()and data.dqy_data.all(): 1621 1627 self.smear_type = "Pinhole2d" 1622 self.dq_l = format_number(np.average(data.dqx_data)) 1623 self.dq_r = format_number(np.average(data.dqy_data)) 1624 return 1628 #report as average dQ/Q % as for 1D pinhole 1629 self.dq_l = format_number(np.average(data.dqx_data 1630 / abs(data.qx_data)) * 100) 1631 self.dq_r = format_number(np.average(data.dqy_data 1632 / abs(data.qy_data)) * 100) 1633 #if not then log that data did not contain resolutin info / abs(data.qy_data)) * 100) 1625 1634 else: 1626 return 1627 # check if it is pinhole smear and get min max if it is. 1628 if data.dx is not None and np.any(data.dx): 1629 self.smear_type = "Pinhole" 1630 self.dq_l = data.dx[0] 1631 self.dq_r = data.dx[-1] 1632 1633 # check if it is slit smear and get min max if it is. 1634 elif data.dxl is not None or data.dxw is not None: 1635 self.smear_type = "Slit" 1636 if data.dxl is not None and np.all(data.dxl, 0): 1637 self.dq_l = data.dxl[0] 1638 if data.dxw is not None and np.all(data.dxw, 0): 1639 self.dq_r = data.dxw[0] 1635 self.msg = "2D Data did not contain recognizable " \ 1636 "resolution info." 1637 logger.info(self.msg) 1638 #If not check that data is 1D 1639 #If so check for pinhole vs slit by veryfing whehter dx or dxl or dxw 1640 #have data (currently sasview only supports either dx or dxl/dxw but 1641 #not both simultaneously) and, as for 2D, are non zero . 1642 #Otherwise no smearing can be applied using smear from data (a Gaussian 1643 #width of zero will cause a divide by zero error) 1644 elif isinstance(self.data, Data1D): 1645 #is it valid 1D pinhole resolution data? 1646 if data.dx is not None and np.all(data.dx): 1647 self.smear_type = "Pinhole" 1648 #report in % for display makes more sense than absolute value 1649 #for pinhole smearing .. but keep old names of dq_l 1650 self.dq_l = format_number(data.dx[0] / data.x[0] * 100,1) 1651 self.dq_r = format_number(data.dx[-1] / data.x[-1] * 100,1) 1652 #If not, is it valid 1D slit resolution data? 1653 elif (data.dxl is not None or data.dxw is not None) \ 1654 and (np.all(data.dxl, 0) or np.all(data.dxw, 0)): 1655 self.smear_type = "Slit" 1656 #for slit units of 1/A make most sense 1657 if data.dxl is not None and np.all(data.dxl, 0): 1658 self.dq_l = format_number(data.dxl[0],1) 1659 if data.dxw is not None and np.all(data.dxw, 0): 1660 self.dq_r = format_number(data.dxw[0],1) 1661 #otherwise log that the data did not conatain resolution info 1662 else: 1663 self.msg = "1D Data did not contain recognizable " \ 1664 "resolution info." 1665 logger.info(self.msg) 1666 #If drops to here it is neither data1D or data2D so log that 1667 else: 1668 self.msg = "Data was not recognized as either 1D or 2D data." 1669 logger.info(self.msg) 1640 1670 # return self.smear_type,self.dq_l,self.dq_r 1641 1671 … … 1644 1674 Show only the sizers depending on smear selection 1645 1675 """ 1646 # smear disabled 1676 # smear disabled = No Smearing used 1647 1677 if self.disable_smearer.GetValue(): 1648 1678 self.smear_description_none.Show(True) 1649 # 2Dsmear 1679 # 2Dsmearing - for use with 2D data only 1650 1680 elif self._is_2D(): 1651 1681 self.smear_description_accuracy_type.Show(True) 1652 1682 self.smear_accuracy.Show(True) 1653 self.smear_description_accuracy_type.Show(True)1654 1683 self.smear_description_2d.Show(True) 1655 self.smear_description_2d_x.Show(True) 1656 self.smear_description_2d_y.Show(True) 1684 #2D custom pinhole smearing 1657 1685 if self.pinhole_smearer.GetValue(): 1686 self.smear_description_pin_percent.Show(True) 1658 1687 self.smear_pinhole_percent.Show(True) 1659 # smear from data 1688 #get 2D smearing from data 1689 elif self.enable_smearer.GetValue(): 1690 self.smear_description_2d_x.Show(True) 1691 self.smear_description_2d_y.Show(True) 1692 self.smear_data_left.Show(True) 1693 self.smear_data_right.Show(True) 1694 #Currently 2D custom slit smearing is not currently supported 1695 else: 1696 logger.error("2D custom smearing cannot use slit smearing") 1697 1698 # 1D smearing from data 1660 1699 elif self.enable_smearer.GetValue(): 1661 1662 1700 self.smear_description_dqdata.Show(True) 1663 1701 if self.smear_type is not None: 1664 1702 self.smear_description_smear_type.Show(True) 1703 #1D data has slit smearing 1665 1704 if self.smear_type == 'Slit': 1666 1705 self.smear_description_slit_height.Show(True) 1667 1706 self.smear_description_slit_width.Show(True) 1707 #1D data has pinhole smearing 1668 1708 elif self.smear_type == 'Pinhole': 1669 self.smear_description_pin_percent.Show(True) 1709 self.smear_description_pin_percent_min.Show(True) 1710 self.smear_description_pin_percent_max.Show(True) 1670 1711 self.smear_description_smear_type.Show(True) 1671 1712 self.smear_description_type.Show(True) 1672 1713 self.smear_data_left.Show(True) 1673 1714 self.smear_data_right.Show(True) 1674 # custom pinhole smear1715 # 1D custom pinhole smearing 1675 1716 elif self.pinhole_smearer.GetValue(): 1676 if self.smear_type == 'Pinhole': 1677 self.smear_message_new_p.Show(True) 1678 self.smear_description_pin_percent.Show(True) 1679 1717 self.smear_message_new_p.Show(True) 1718 self.smear_description_pin_percent.Show(True) 1680 1719 self.smear_pinhole_percent.Show(True) 1681 # custom slit smear1720 # 1D custom slit smear 1682 1721 elif self.slit_smearer.GetValue(): 1683 1722 self.smear_message_new_s.Show(True) … … 1686 1725 self.smear_description_slit_width.Show(True) 1687 1726 self.smear_slit_width.Show(True) 1727 else: 1728 logger.error("smearing type is not defined") 1688 1729 1689 1730 def _hide_all_smear_info(self): … … 1703 1744 self.smear_data_left.Hide() 1704 1745 self.smear_data_right.Hide() 1746 self.smear_description_pin_percent_min.Hide() 1747 self.smear_description_pin_percent_max.Hide() 1705 1748 self.smear_description_pin_percent.Hide() 1706 1749 self.smear_pinhole_percent.Hide() … … 1920 1963 di_flag = False 1921 1964 dq_flag = False 1922 if self.data.__class__.__name__ == "Data2D" or \ 1923 self.enable2D: 1965 if isinstance(self.data, Data2D) or self.enable2D: 1924 1966 self.slit_smearer.Disable() 1925 1967 self.pinhole_smearer.Enable(True) … … 2006 2048 # update model plot with new data information 2007 2049 if flag: 2008 if self.data.__class__.__name__ == "Data2D":2050 if isinstance(self.data, Data2D): 2009 2051 self.enable2D = True 2010 2052 self.model_view.SetLabel("2D Mode") … … 2073 2115 npts2fit = 0 2074 2116 qmin, qmax = self.get_range() 2075 if self.data.__class__.__name__ == "Data2D" or \ 2076 self.enable2D: 2117 if isinstance(self.data, Data2D) or self.enable2D: 2077 2118 radius = np.sqrt(self.data.qx_data * self.data.qx_data + 2078 2119 self.data.qy_data * self.data.qy_data) … … 2464 2505 of the values entered for slit smear 2465 2506 """ 2466 if self.data.__class__.__name__ == "Data2D"or self.enable2D:2507 if isinstance(self.data, Data2D) or self.enable2D: 2467 2508 return 2468 2509 # make sure once more if it is smearer … … 2660 2701 for item in self.parameters: 2661 2702 # Skip t ifhe angle parameters if 1D data 2662 if self.data.__class__.__name__ != "Data2D" and\ 2663 not self.enable2D: 2703 if not isinstance(self.data, Data2D) and not self.enable2D: 2664 2704 if item in self.orientation_params: 2665 2705 continue … … 2677 2717 for item in self.fittable_param: 2678 2718 # Skip t ifhe angle parameters if 1D data 2679 if self.data.__class__.__name__ != "Data2D" and\ 2680 not self.enable2D: 2719 if not isinstance(self.data, Data2D) and not self.enable2D: 2681 2720 if item in self.orientation_params: 2682 2721 continue … … 2690 2729 2691 2730 # Calculate num. of angle parameters 2692 if self.data.__class__.__name__ == "Data2D" or \ 2693 self.enable2D: 2731 if isinstance(self.data, Data2D) or self.enable2D: 2694 2732 len_orient_para = 0 2695 2733 else: … … 2984 3022 if not self._has_magnetic: 2985 3023 mag_on_button.Show(False) 2986 elif not self.data.__class__.__name__ == "Data2D":3024 elif not isinstance(self.data, Data2D): 2987 3025 mag_on_button.Show(False) 2988 3026 else: … … 3000 3038 mag_angle_help_button.Show(False) 3001 3039 3002 if not self.data.__class__.__name__ == "Data2D" and \ 3003 not self.enable2D: 3040 if not isinstance(self.data, Data2D) and not self.enable2D: 3004 3041 orient_angle.Hide() 3005 3042 else: … … 3025 3062 cb.SetToolTipString("Check mark to fit") 3026 3063 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 3027 if self.data.__class__.__name__ == "Data2D" or \ 3028 self.enable2D: 3064 if isinstance(self.data, Data2D) or self.enable2D: 3029 3065 cb.Show(True) 3030 3066 else: … … 3041 3077 "Hit 'Enter' after typing to update the plot.") 3042 3078 ctl1.SetValue(format_number(value, True)) 3043 if self.data.__class__.__name__ == "Data2D" or \ 3044 self.enable2D: 3079 if isinstance(self.data, Data2D) or self.enable2D: 3045 3080 ctl1.Show(True) 3046 3081 else: … … 3082 3117 ctl4.Hide() 3083 3118 3084 if self.data.__class__.__name__ == "Data2D" or \ 3085 self.enable2D: 3119 if isinstance(self.data, Data2D) or self.enable2D: 3086 3120 if self.is_mac: 3087 3121 text2.Show(True) … … 3099 3133 units = wx.StaticText(self, -1, "", 3100 3134 style=wx.ALIGN_LEFT) 3101 if self.data.__class__.__name__ == "Data2D" or \ 3102 self.enable2D: 3135 if isinstance(self.data, Data2D) or self.enable2D: 3103 3136 units.Show(True) 3104 3137 else: … … 3179 3212 """ 3180 3213 # more disables for 2D 3181 if self.data.__class__.__name__ == "Data2D" or \ 3182 self.enable2D: 3214 if isinstance(self.data, Data2D) or self.enable2D: 3183 3215 self.slit_smearer.Disable() 3184 self.pinhole_smearer.Enable(True)3185 3216 self.default_mask = copy.deepcopy(self.data.mask) 3186 else: 3187 self.slit_smearer.Enable(True) 3188 self.pinhole_smearer.Enable(True) 3217 if self.model is not None: 3218 self.pinhole_smearer.Enable(True) 3219 3220 elif isinstance(self.data, Data1D): 3221 if self.model is not None: 3222 self.slit_smearer.Enable(True) 3223 self.pinhole_smearer.Enable(True) 3224 else: 3225 msg="data is not recognized as either 1D or 2D" 3226 logger.info(msg) 3189 3227 3190 3228 -
src/sas/sasgui/perspectives/fitting/fitting.py
raba4559 ra5cffe5 776 776 :param weight: current dy data 777 777 """ 778 # If we are not dealing with a specific fit problem, then 779 # there is no point setting the weights. 780 if fid is None: 781 return 778 # Note: this is used to set the data weights for the fit based on 779 # the weight selection in the GUI. 782 780 if uid in self.page_finder.keys(): 783 781 self.page_finder[uid].set_weight(flag=flag, is2d=is2d) -
src/sas/sasgui/perspectives/fitting/gpu_options.py
r388aefb r895703d 8 8 ''' 9 9 10 import json 11 import platform 10 12 import logging 11 13 import os 12 14 import sys 15 13 16 import wx 17 18 try: 19 import pyopencl as cl 20 except ImportError: 21 cl = None 22 14 23 import sasmodels 24 import sasmodels.model_test 25 import sasmodels.sasview_model 26 15 27 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 16 28 … … 169 181 clinfo = [] 170 182 platforms = [] 171 try: 172 import pyopencl as cl 173 platforms = cl.get_platforms() 174 except ImportError: 183 184 if cl is None: 175 185 logger.warn("Unable to import the pyopencl package. It may not " 176 186 "have been installed. If you wish to use OpenCL, try " 177 187 "running pip install --user pyopencl") 178 except cl.LogicError as err: 179 logger.warn("Unable to fetch the OpenCL platforms. This likely " 180 "means that the opencl drivers for your system are " 181 "not installed.") 182 logger.warn(err) 188 else: 189 try: 190 platforms = cl.get_platforms() 191 except cl.LogicError as err: 192 logger.warn("Unable to fetch the OpenCL platforms. This likely " 193 "means that the opencl drivers for your system are " 194 "not installed.") 195 logger.warn(err) 183 196 184 197 p_index = 0 … … 226 239 if "SAS_OPENCL" in os.environ: 227 240 del os.environ["SAS_OPENCL"] 228 229 #Sasmodels kernelcl doesn't exist when initiated with None 230 if 'sasmodels.kernelcl' in sys.modules: 231 sasmodels.kernelcl.ENV = None 232 233 reload(sasmodels.core) 241 sasmodels.sasview_model.reset_environment() 234 242 event.Skip() 235 243 … … 247 255 Run sasmodels check from here and report results from 248 256 """ 249 import json250 import platform251 #import sasmodels252 253 257 #The same block of code as for OK but it is needed if we want to have 254 258 #active response to Test button … … 261 265 if "SAS_OPENCL" in os.environ: 262 266 del os.environ["SAS_OPENCL"] 263 264 #Sasmodels kernelcl doesn't exist when initiated with None 265 if 'sasmodels.kernelcl' in sys.modules: 266 sasmodels.kernelcl.ENV = None 267 268 269 #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 270 reload(sasmodels.core) 271 272 273 from sasmodels.model_test import model_tests 267 sasmodels.sasview_model.reset_environment() 274 268 275 269 try: 276 from sasmodels.kernelcl import environment 277 env = environment() 270 env = sasmodels.kernelcl.environment() 278 271 clinfo = [(ctx.devices[0].platform.vendor, 279 272 ctx.devices[0].platform.version, … … 282 275 ctx.devices[0].version) 283 276 for ctx in env.context] 284 except ImportError:277 except Exception: 285 278 clinfo = None 286 279 287 280 failures = [] 288 281 tests_completed = 0 289 for test in model_tests():282 for test in sasmodels.model_test.model_tests(): 290 283 try: 291 284 test() -
src/sas/sasgui/plottools/PlotPanel.py
r2469df7 r75313af 1434 1434 1435 1435 """ 1436 # TODO: include mask info in plotter 1436 1437 self.data = data 1437 1438 self.qx_data = qx_data … … 1451 1452 else: 1452 1453 output = copy.deepcopy(self.data) 1453 # check scale1454 # rescale data if necessary 1454 1455 if self.scale == 'log_{10}': 1455 try: 1456 if self.zmin_2D <= 0 and len(output[output > 0]) > 0: 1457 zmin_temp = self.zmin_2D 1458 output[output > 0] = np.log10(output[output > 0]) 1459 #In log scale Negative values are not correct in general 1460 #output[output<=0] = math.log(np.min(output[output>0])) 1461 elif self.zmin_2D <= 0: 1462 zmin_temp = self.zmin_2D 1463 output[output > 0] = np.zeros(len(output)) 1464 output[output <= 0] = -32 1465 else: 1466 zmin_temp = self.zmin_2D 1467 output[output > 0] = np.log10(output[output > 0]) 1468 #In log scale Negative values are not correct in general 1469 #output[output<=0] = math.log(np.min(output[output>0])) 1470 except: 1471 #Too many problems in 2D plot with scale 1472 pass 1473 1474 else: 1475 zmin_temp = self.zmin_2D 1456 with np.errstate(all='ignore'): 1457 output = np.log10(output) 1458 index = np.isfinite(output) 1459 if not index.all(): 1460 cutoff = (np.min(output[index]) - np.log10(2) 1461 if index.any() else 0.) 1462 output[~index] = cutoff 1463 # TODO: fix handling of zmin_2D/zmax_2D in _onToggleScale 1464 # For now, use default vmin/vmax from data 1465 #vmin, vmax = self.zmin_2D, self.zmax_2D 1466 vmin, vmax = None, None 1476 1467 self.cmap = cmap 1477 1468 if self.dimension != 3: 1478 1469 #Re-adjust colorbar 1479 1470 self.subplot.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 1480 1481 1471 im = self.subplot.imshow(output, interpolation='nearest', 1482 1472 origin='lower', 1483 vmin= zmin_temp, vmax=self.zmax_2D,1473 vmin=vmin, vmax=vmax, 1484 1474 cmap=self.cmap, 1485 1475 extent=(self.xmin_2D, self.xmax_2D, -
src/sas/sasview/__init__.py
rb229a3b r5e16b30 1 __version__ = "4.2.0" 1 from distutils.version import StrictVersion 2 __version__ = "4.2.1" 3 StrictVersion(__version__) 4 __DOI__ = "Zenodo, 10.5281/zenodo.2561236" 5 __release_date__ = "2019" 2 6 __build__ = "GIT_COMMIT" -
src/sas/sasview/local_config.py
r1b4cb41 r839f70f7 16 16 __appname__ = "SasView" 17 17 __version__ = sas.sasview.__version__ 18 __DOI__ = sas.sasview.__DOI__ 19 __release_date__ = sas.sasview.__release_date__ 18 20 __build__ = sas.sasview.__build__ 19 21 __download_page__ = 'https://github.com/SasView/sasview/releases' … … 36 38 _do_tutorial = True 37 39 _acknowledgement_preamble =\ 38 '''To ensure the long term support and development of this software please ''' +\39 '''remember to:'''40 '''To ensure the long term support and development of this software please 41 remember to:''' 40 42 _acknowledgement_preamble_bullet1 =\ 41 43 '''Acknowledge its use in your publications as :''' … … 47 49 '''Send us your reference for our records: developers@sasview.org''' 48 50 _acknowledgement_publications = \ 49 '''This work benefited from the use of the SasView application, originally developed under NSF Award DMR-0520547. SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project Grant No 654000.''' 51 ("This work benefited from the use of the SasView application, originally" 52 "developed under NSF Award DMR-0520547. SasView also contains code developed" 53 "with funding from the EU Horizon 2020 programme under the SINE2020 project" 54 "Grant No 654000.") 50 55 _acknowledgement_citation = \ 51 '''M. Doucet et al. SasView Version 4.2, Zenodo, 10.5281/zenodo.1412041'''56 '''M. Doucet et al. SasView Version %s, %s''' % (__version__, __DOI__) 52 57 _acknowledgement = \ 53 '''This work was originally developed as part of the DANSE project funded by the US NSF under Award DMR-0520547,\n but is currently maintained by a collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS, BAM and the scattering community.\n\n SasView also contains code developed with funding from the EU Horizon 2020 programme under the SINE2020 project (Grant No 654000).\nA list of individual contributors can be found at: http://www.sasview.org/contact.html 54 ''' 58 ("This work was originally developed as part of the DANSE project funded by" 59 "the US NSF under Award DMR-0520547,\n but is currently maintained by a" 60 "collaboration between UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft," 61 "DLS, BAM and the scattering community.\n\n SasView also contains code" 62 "developed with funding from the EU Horizon 2020 programme under the SINE2020" 63 "project (Grant No 654000).\nA list of individual contributors can be found" 64 "at: http://www.sasview.org/contact.html") 55 65 56 66 _homepage = "http://www.sasview.org" … … 95 105 _corner_image = os.path.join(icon_path, "angles_flat.png") 96 106 _welcome_image = os.path.join(icon_path, "SVwelcome.png") 97 _copyright = "(c) 2009 - 2018, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, DLS and BAM" 107 _copyright = ("(c) 2009 - %s, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO," 108 "TU Delft, DLS and BAM") % __release_date__ 98 109 marketplace_url = "http://marketplace.sasview.org/" 99 110 -
src/sas/sascalc/corfunc/corfunc_calculator.py
re090ba90 rdbfd307 245 245 """Fit the Guinier region of the curve""" 246 246 A = np.vstack([q**2, np.ones(q.shape)]).T 247 return lstsq(A, np.log(iq), rcond=None) 247 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 248 rcond = np.finfo(float).eps * max(A.shape) 249 return lstsq(A, np.log(iq), rcond=rcond) 248 250 249 251 def _fit_porod(self, q, iq): -
src/sas/sascalc/invariant/invariant.py
re090ba90 rdbfd307 344 344 else: 345 345 A = np.vstack([linearized_data.x / linearized_data.dy, 1.0 / linearized_data.dy]).T 346 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 347 rcond = np.finfo(float).eps * max(A.shape) 346 348 p, residuals, _, _ = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy, 347 rcond= None)349 rcond=rcond) 348 350 349 351 # Get the covariance matrix, defined as inv_cov = a_transposed * a
Note: See TracChangeset
for help on using the changeset viewer.