Changeset e78edc4 in sasmodels
- Timestamp:
- Apr 14, 2016 10:41:17 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 7abcc59
- Parents:
- 62cf915
- git-author:
- Paul Kienzle <pkienzle@…> (04/14/16 10:37:03)
- git-committer:
- Paul Kienzle <pkienzle@…> (04/14/16 10:41:17)
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
rf247314 re78edc4 58 58 -lowq*/-midq/-highq/-exq use q values up to 0.05, 0.2, 1.0, 10.0 59 59 -nq=128 sets the number of Q points in the data set 60 -zero indicates that q=0 should be included 60 61 -1d*/-2d computes 1d or 2d data 61 62 -preset*/-random[=seed] preset or random parameters … … 476 477 index = ~data.mask 477 478 else: 478 if opts['view'] == 'log' :479 if opts['view'] == 'log' and not opts['zero']: 479 480 qmax = math.log10(qmax) 480 481 q = np.logspace(qmax-3, qmax, nq) 481 482 else: 482 483 q = np.linspace(0.001*qmax, qmax, nq) 484 if opts['zero']: 485 q = np.hstack((0, q)) 483 486 data = empty_data1D(q, resolution=res) 484 487 index = slice(None, None) … … 498 501 else: 499 502 return eval_opencl(model_info, data, dtype=dtype, cutoff=cutoff) 503 504 def _show_invalid(data, theory): 505 if not theory.mask.any(): 506 return 507 508 if hasattr(data, 'x'): 509 bad = zip(data.x[theory.mask], theory[theory.mask]) 510 print(" *** ", ", ".join("I(%g)=%g"%(x, y) for x,y in bad)) 511 500 512 501 513 def compare(opts, limits=None): … … 519 531 try: 520 532 base_value, base_time = time_calculation(base, pars, Nbase) 533 base_value = np.ma.masked_invalid(base_value) 521 534 print("%s t=%.2f ms, intensity=%.0f" 522 % (base.engine, base_time, sum(base_value))) 535 % (base.engine, base_time, base_value.sum())) 536 _show_invalid(data, base_value) 523 537 except ImportError: 524 538 traceback.print_exc() … … 530 544 try: 531 545 comp_value, comp_time = time_calculation(comp, pars, Ncomp) 546 comp_value = np.ma.masked_invalid(comp_value) 532 547 print("%s t=%.2f ms, intensity=%.0f" 533 % (comp.engine, comp_time, sum(comp_value))) 548 % (comp.engine, comp_time, comp_value.sum())) 549 _show_invalid(data, comp_value) 534 550 except ImportError: 535 551 traceback.print_exc() … … 554 570 vmin, vmax = np.Inf, -np.Inf 555 571 if Nbase > 0: 556 vmin = min(vmin, min(base_value))557 vmax = max(vmax, max(base_value))572 vmin = min(vmin, base_value.min()) 573 vmax = max(vmax, base_value.max()) 558 574 if Ncomp > 0: 559 vmin = min(vmin, min(comp_value))560 vmax = max(vmax, max(comp_value))575 vmin = min(vmin, comp_value.min()) 576 vmax = max(vmax, comp_value.max()) 561 577 limits = vmin, vmax 562 578 … … 581 597 if view == 'linear': 582 598 plt.xscale('linear') 583 plt.title("max %s = %.3g"%(errstr, max(abs(err))))599 plt.title("max %s = %.3g"%(errstr, abs(err).max())) 584 600 #cbar_title = errstr if errview=="linear" else "log "+errstr 585 601 #if is2D: … … 603 619 604 620 def _print_stats(label, err): 605 sorted_err = np.sort(abs(err ))621 sorted_err = np.sort(abs(err.compressed())) 606 622 p50 = int((len(err)-1)*0.50) 607 623 p98 = int((len(err)-1)*0.98) … … 623 639 'half', 'fast', 'single', 'double', 624 640 'single!', 'double!', 'quad!', 'sasview', 625 'lowq', 'midq', 'highq', 'exq', 641 'lowq', 'midq', 'highq', 'exq', 'zero', 626 642 '2d', '1d', 627 643 'preset', 'random', … … 700 716 try: 701 717 model_info = core.load_model_info(name) 702 except ImportError ,exc:718 except ImportError as exc: 703 719 print(str(exc)) 704 720 print("Could not find model; use one of:\n " + models) … … 745 761 elif arg == '-midq': opts['qmax'] = 0.2 746 762 elif arg == '-lowq': opts['qmax'] = 0.05 763 elif arg == '-zero': opts['zero'] = True 747 764 elif arg.startswith('-nq='): opts['nq'] = int(arg[4:]) 748 765 elif arg.startswith('-res='): opts['res'] = float(arg[5:]) -
sasmodels/data.py
rd6f5da6 re78edc4 380 380 use_calc = use_theory and Iq_calc is not None 381 381 num_plots = (use_data or use_theory) + use_calc + use_resid 382 382 non_positive_x = (data.x<=0.0).any() 383 383 384 384 scale = data.x**4 if view == 'q4' else 1.0 … … 402 402 403 403 if use_theory: 404 # Note: masks merge, so any masked theory points will stay masked, 405 # and the data mask will be added to it. 404 406 mtheory = masked_array(theory, data.mask.copy()) 405 407 mtheory[~np.isfinite(mtheory)] = masked … … 413 415 plt.ylim(*limits) 414 416 415 plt.xscale('linear' if not some_present else view)417 plt.xscale('linear' if not some_present or non_positive_x else view) 416 418 plt.yscale('linear' 417 419 if view == 'q4' or not some_present or not all_positive … … 441 443 plt.xlabel("$q$/A$^{-1}$") 442 444 plt.ylabel('residuals') 443 plt.xscale('linear' if not some_present else view)445 plt.xscale('linear' if not some_present or non_positive_x else view) 444 446 445 447 -
sasmodels/model_test.py
r4d76711 re78edc4 145 145 def _runTest(self): 146 146 smoke_tests = [ 147 # test validity at reasonable values 147 148 [{}, 0.1, None], 148 149 [{}, (0.1, 0.1), None], 150 # test validity at q = 0 151 #[{}, 0.0, None], 152 #[{}, (0.0, 0.0), None], 153 # test that ER/VR will run if they exist 149 154 [{}, 'ER', None], 150 155 [{}, 'VR', None], … … 194 199 actual = call_kernel(kernel, pars) 195 200 196 self.assert Greater(len(actual),0)201 self.assertTrue(len(actual) > 0) 197 202 self.assertEqual(len(y), len(actual)) 198 203
Note: See TracChangeset
for help on using the changeset viewer.