Changeset 84f2962 in sasmodels
- Timestamp:
- Sep 8, 2018 5:27:56 AM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- c88f983
- Parents:
- c0131d44
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
r117c02a r84f2962 381 381 continue 382 382 self.params[p.name] = p.default 383 if p.limits is not None: 384 self.details[p.id] = [p.units if not p.choices else p.choices, p.limits[0], p.limits[1]] 385 else: 386 self.details[p.id] = [p.units if not p.choices else p.choices, None, None] 383 self.details[p.id] = [p.units, p.limits[0], p.limits[1]] 387 384 if p.polydisperse: 388 385 self.details[p.id+".width"] = [ … … 543 540 # pylint: disable=unpacking-non-sequence 544 541 q, phi = x 545 return self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)])[0] 546 else: 547 return self.calculate_Iq([x])[0] 542 result, _ = self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)]) 543 return result[0] 544 else: 545 result, _ = self.calculate_Iq([x]) 546 return result[0] 548 547 549 548 … … 560 559 """ 561 560 if isinstance(x, (list, tuple)): 562 return self.calculate_Iq([x[0]], [x[1]])[0] 563 else: 564 return self.calculate_Iq([x])[0] 561 result, _ = self.calculate_Iq([x[0]], [x[1]]) 562 return result[0] 563 else: 564 result, _ = self.calculate_Iq([x]) 565 return result[0] 565 566 566 567 def evalDistribution(self, qdist): … … 596 597 # Check whether we have a list of ndarrays [qx,qy] 597 598 qx, qy = qdist 598 return self.calculate_Iq(qx, qy) 599 result, _ = self.calculate_Iq(qx, qy) 600 return result 599 601 600 602 elif isinstance(qdist, np.ndarray): 601 603 # We have a simple 1D distribution of q-values 602 return self.calculate_Iq(qdist) 604 result, _ = self.calculate_Iq(qdist) 605 return result 603 606 604 607 else: … … 640 643 if composition and composition[0] == 'product': # only P*S for now 641 644 with calculation_lock: 642 self._calculate_Iq(qx) 643 # for compatibility with sasview 4.3 644 results = self._intermediate_results() 645 return results["P(Q)"], results["S(Q)"] 645 _, lazy_results = self._calculate_Iq(qx) 646 # for compatibility with sasview 4.x 647 results = lazy_results() 648 pq_data = results.get("P(Q)") 649 sq_data = results.get("S(Q)") 650 return pq_data, sq_data 646 651 else: 647 652 return None 648 653 649 def calculate_Iq(self, qx, qy=None): 650 # type: (Sequence[float], Optional[Sequence[float]]) -> np.ndarray 654 def calculate_Iq(self, 655 qx, # type: Sequence[float] 656 qy=None # type: Optional[Sequence[float]] 657 ): 658 # type: (...) -> Tuple[np.ndarray, Callable[[], collections.OrderedDict[str, np.ndarray]]] 651 659 """ 652 660 Calculate Iq for one set of q with the current parameters. … … 656 664 This should NOT be used for fitting since it copies the *q* vectors 657 665 to the card for each evaluation. 666 667 The returned tuple contains the scattering intensity followed by a 668 callable which returns a dictionary of intermediate data from 669 ProductKernel. 658 670 """ 659 671 ## uncomment the following when trying to debug the uncoordinated calls … … 688 700 result = calculator(call_details, values, cutoff=self.cutoff, 689 701 magnetic=is_magnetic) 702 lazy_results = getattr(calculator, 'results', 703 lambda: collections.OrderedDict()) 690 704 #print("result", result) 691 self._intermediate_results = getattr(calculator, 'results', None) 705 692 706 calculator.release() 693 707 #self._model.release() 694 return result 708 709 return result, lazy_results 695 710 696 711 def calculate_ER(self): … … 881 896 q = np.linspace(-0.35, 0.35, 500) 882 897 qx, qy = np.meshgrid(q, q) 883 result = model.calculate_Iq(qx.flatten(), qy.flatten())898 result, _ = model.calculate_Iq(qx.flatten(), qy.flatten()) 884 899 result = result.reshape(qx.shape) 885 900
Note: See TracChangeset
for help on using the changeset viewer.