Changeset 2773c66 in sasmodels for sasmodels/sasview_model.py
- Timestamp:
- Sep 8, 2018 8:29:05 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:
- ba51e00
- Parents:
- b763f9d (diff), c88f983 (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/sasview_model.py
raa44a6a r2773c66 543 543 # pylint: disable=unpacking-non-sequence 544 544 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] 545 result, _ = self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)]) 546 return result[0] 547 else: 548 result, _ = self.calculate_Iq([x]) 549 return result[0] 548 550 549 551 … … 560 562 """ 561 563 if isinstance(x, (list, tuple)): 562 return self.calculate_Iq([x[0]], [x[1]])[0] 563 else: 564 return self.calculate_Iq([x])[0] 564 result, _ = self.calculate_Iq([x[0]], [x[1]]) 565 return result[0] 566 else: 567 result, _ = self.calculate_Iq([x]) 568 return result[0] 565 569 566 570 def evalDistribution(self, qdist): … … 596 600 # Check whether we have a list of ndarrays [qx,qy] 597 601 qx, qy = qdist 598 return self.calculate_Iq(qx, qy) 602 result, _ = self.calculate_Iq(qx, qy) 603 return result 599 604 600 605 elif isinstance(qdist, np.ndarray): 601 606 # We have a simple 1D distribution of q-values 602 return self.calculate_Iq(qdist) 607 result, _ = self.calculate_Iq(qdist) 608 return result 603 609 604 610 else: … … 640 646 if composition and composition[0] == 'product': # only P*S for now 641 647 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)"] 648 _, lazy_results = self._calculate_Iq(qx) 649 # for compatibility with sasview 4.x 650 results = lazy_results() 651 pq_data = results.get("P(Q)") 652 sq_data = results.get("S(Q)") 653 return pq_data, sq_data 646 654 else: 647 655 return None 648 656 649 def calculate_Iq(self, qx, qy=None): 650 # type: (Sequence[float], Optional[Sequence[float]]) -> np.ndarray 657 def calculate_Iq(self, 658 qx, # type: Sequence[float] 659 qy=None # type: Optional[Sequence[float]] 660 ): 661 # type: (...) -> Tuple[np.ndarray, Callable[[], collections.OrderedDict[str, np.ndarray]]] 651 662 """ 652 663 Calculate Iq for one set of q with the current parameters. … … 656 667 This should NOT be used for fitting since it copies the *q* vectors 657 668 to the card for each evaluation. 669 670 The returned tuple contains the scattering intensity followed by a 671 callable which returns a dictionary of intermediate data from 672 ProductKernel. 658 673 """ 659 674 ## uncomment the following when trying to debug the uncoordinated calls … … 688 703 result = calculator(call_details, values, cutoff=self.cutoff, 689 704 magnetic=is_magnetic) 705 lazy_results = getattr(calculator, 'results', 706 lambda: collections.OrderedDict()) 690 707 #print("result", result) 691 self._intermediate_results = getattr(calculator, 'results', None) 708 692 709 calculator.release() 693 710 #self._model.release() 694 return result 711 712 return result, lazy_results 695 713 696 714 def calculate_ER(self): … … 881 899 q = np.linspace(-0.35, 0.35, 500) 882 900 qx, qy = np.meshgrid(q, q) 883 result = model.calculate_Iq(qx.flatten(), qy.flatten())901 result, _ = model.calculate_Iq(qx.flatten(), qy.flatten()) 884 902 result = result.reshape(qx.shape) 885 903
Note: See TracChangeset
for help on using the changeset viewer.