Changes in / [0ce5710:b151003] in sasmodels
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r7ae2b7f re78edc4 57 57 -lowq*/-midq/-highq/-exq use q values up to 0.05, 0.2, 1.0, 10.0 58 58 -nq=128 sets the number of Q points in the data set 59 -zero indicates that q=0 should be included 59 60 -1d*/-2d computes 1d or 2d data 60 61 -preset*/-random[=seed] preset or random parameters … … 482 483 index = ~data.mask 483 484 else: 484 if opts['view'] == 'log' :485 if opts['view'] == 'log' and not opts['zero']: 485 486 qmax = math.log10(qmax) 486 487 q = np.logspace(qmax-3, qmax, nq) 487 488 else: 488 489 q = np.linspace(0.001*qmax, qmax, nq) 490 if opts['zero']: 491 q = np.hstack((0, q)) 489 492 data = empty_data1D(q, resolution=res) 490 493 index = slice(None, None) … … 505 508 return eval_opencl(model_info, data, dtype=dtype, cutoff=cutoff) 506 509 510 def _show_invalid(data, theory): 511 if not theory.mask.any(): 512 return 513 514 if hasattr(data, 'x'): 515 bad = zip(data.x[theory.mask], theory[theory.mask]) 516 print(" *** ", ", ".join("I(%g)=%g"%(x, y) for x,y in bad)) 517 518 507 519 def compare(opts, limits=None): 508 520 """ … … 525 537 try: 526 538 base_value, base_time = time_calculation(base, pars, Nbase) 539 base_value = np.ma.masked_invalid(base_value) 527 540 print("%s t=%.2f ms, intensity=%.0f" 528 % (base.engine, base_time, sum(base_value))) 541 % (base.engine, base_time, base_value.sum())) 542 _show_invalid(data, base_value) 529 543 except ImportError: 530 544 traceback.print_exc() … … 536 550 try: 537 551 comp_value, comp_time = time_calculation(comp, pars, Ncomp) 552 comp_value = np.ma.masked_invalid(comp_value) 538 553 print("%s t=%.2f ms, intensity=%.0f" 539 % (comp.engine, comp_time, sum(comp_value))) 554 % (comp.engine, comp_time, comp_value.sum())) 555 _show_invalid(data, comp_value) 540 556 except ImportError: 541 557 traceback.print_exc() … … 560 576 vmin, vmax = np.Inf, -np.Inf 561 577 if Nbase > 0: 562 vmin = min(vmin, min(base_value))563 vmax = max(vmax, max(base_value))578 vmin = min(vmin, base_value.min()) 579 vmax = max(vmax, base_value.max()) 564 580 if Ncomp > 0: 565 vmin = min(vmin, min(comp_value))566 vmax = max(vmax, max(comp_value))581 vmin = min(vmin, comp_value.min()) 582 vmax = max(vmax, comp_value.max()) 567 583 limits = vmin, vmax 568 584 … … 587 603 if view == 'linear': 588 604 plt.xscale('linear') 589 plt.title("max %s = %.3g"%(errstr, max(abs(err))))605 plt.title("max %s = %.3g"%(errstr, abs(err).max())) 590 606 #cbar_title = errstr if errview=="linear" else "log "+errstr 591 607 #if is2D: … … 609 625 610 626 def _print_stats(label, err): 611 sorted_err = np.sort(abs(err ))627 sorted_err = np.sort(abs(err.compressed())) 612 628 p50 = int((len(err)-1)*0.50) 613 629 p98 = int((len(err)-1)*0.98) … … 629 645 'half', 'fast', 'single', 'double', 630 646 'single!', 'double!', 'quad!', 'sasview', 631 'lowq', 'midq', 'highq', 'exq', 647 'lowq', 'midq', 'highq', 'exq', 'zero', 632 648 '2d', '1d', 633 649 'preset', 'random', … … 755 771 elif arg == '-midq': opts['qmax'] = 0.2 756 772 elif arg == '-lowq': opts['qmax'] = 0.05 773 elif arg == '-zero': opts['zero'] = True 757 774 elif arg.startswith('-nq='): opts['nq'] = int(arg[4:]) 758 775 elif arg.startswith('-res='): opts['res'] = float(arg[5:]) -
sasmodels/data.py
ra5b8477 re78edc4 410 410 use_calc = use_theory and Iq_calc is not None 411 411 num_plots = (use_data or use_theory) + use_calc + use_resid 412 412 non_positive_x = (data.x<=0.0).any() 413 413 414 414 scale = data.x**4 if view == 'q4' else 1.0 … … 432 432 433 433 if use_theory: 434 # Note: masks merge, so any masked theory points will stay masked, 435 # and the data mask will be added to it. 434 436 mtheory = masked_array(theory, data.mask.copy()) 435 437 mtheory[~np.isfinite(mtheory)] = masked … … 443 445 plt.ylim(*limits) 444 446 445 plt.xscale('linear' if not some_present else view)447 plt.xscale('linear' if not some_present or non_positive_x else view) 446 448 plt.yscale('linear' 447 449 if view == 'q4' or not some_present or not all_positive … … 471 473 plt.xlabel("$q$/A$^{-1}$") 472 474 plt.ylabel('residuals') 473 plt.xscale('linear' if not some_present else view)475 plt.xscale('linear' if not some_present or non_positive_x else view) 474 476 475 477 -
sasmodels/model_test.py
r7ae2b7f re78edc4 43 43 Precision defaults to 5 digits (relative). 44 44 """ 45 #TODO: rename to tests so that tab completion works better for models directory46 47 45 from __future__ import print_function 48 46 … … 197 195 # type: () -> None 198 196 smoke_tests = [ 197 # test validity at reasonable values 199 198 ({}, 0.1, None), 200 199 ({}, (0.1, 0.1), None), 200 # test validity at q = 0 201 #({}, 0.0, None), 202 #({}, (0.0, 0.0), None), 203 # test that ER/VR will run if they exist 201 204 ({}, 'ER', None), 202 205 ({}, 'VR', None), -
sasmodels/models/adsorbed_layer.py
r62cf915 r7abcc59 65 65 66 66 # pylint: disable=bad-whitespace, line-too-long 67 # 67 # ["name", "units", default, [lower, upper], "type", "description"], 68 68 parameters = [ 69 69 ["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment of polymer distribution"], … … 75 75 ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent SLD"], 76 76 ] 77 # pylint: disable=bad-whitespace, line-too-long77 # pylint: enable=bad-whitespace, line-too-long 78 78 79 79 # NB: Scale and Background are implicit parameters on every model
Note: See TracChangeset
for help on using the changeset viewer.