Changeset b151003 in sasmodels for sasmodels/compare.py
- Timestamp:
- Apr 14, 2016 8:57:32 AM (8 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:
- 391ea92, dd7fc12
- Parents:
- 0ce5710 (diff), 7abcc59 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r7ae2b7f rb151003 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:])
Note: See TracChangeset
for help on using the changeset viewer.