Changeset 6e7ff6d in sasmodels for sasmodels/generate.py
- Timestamp:
- Apr 7, 2016 2:01:54 PM (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:
- 3543141
- Parents:
- 8bd7b77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
r4937980 r6e7ff6d 125 125 An *model_info* dictionary is constructed from the kernel meta data and 126 126 returned to the caller. 127 128 The model evaluator, function call sequence consists of q inputs and the return vector,129 followed by the loop value/weight vector, followed by the values for130 the non-polydisperse parameters, followed by the lengths of the131 polydispersity loops. To construct the call for 1D models, the132 categories *fixed-1d* and *pd-1d* list the names of the parameters133 of the non-polydisperse and the polydisperse parameters respectively.134 Similarly, *fixed-2d* and *pd-2d* provide parameter names for 2D models.135 The *pd-rel* category is a set of those parameters which give136 polydispersitiy as a portion of the value (so a 10% length dispersity137 would use a polydispersity value of 0.1) rather than absolute138 dispersity such as an angle plus or minus 15 degrees.139 140 The *volume* category lists the volume parameters in order for calls141 to volume within the kernel (used for volume normalization) and for142 calls to ER and VR for effective radius and volume ratio respectively.143 144 The *orientation* and *magnetic* categories list the orientation and145 magnetic parameters. These are used by the sasview interface. The146 blank category is for parameters such as scale which don't have any147 other marking.148 127 149 128 The doc string at the start of the kernel module will be used to … … 552 531 @property 553 532 def ctypes(self): return self.details.ctypes 533 554 534 @property 555 535 def pd_par(self): return self._pd_par 536 556 537 @property 557 538 def pd_length(self): return self._pd_length 539 558 540 @property 559 541 def pd_offset(self): return self._pd_offset 542 560 543 @property 561 544 def pd_stride(self): return self._pd_stride 545 562 546 @property 563 547 def pd_coord(self): return self._pd_coord 548 564 549 @property 565 550 def par_coord(self): return self._par_coord 551 566 552 @property 567 553 def par_offset(self): return self._par_offset 554 555 @property 556 def num_active(self): return self.details[-4] 557 @num_active.setter 558 def num_active(self, v): self.details[-4] = v 559 560 @property 561 def total_pd(self): return self.details[-3] 562 @total_pd.setter 563 def total_pd(self, v): self.details[-3] = v 564 568 565 @property 569 566 def num_coord(self): return self.details[-2] 570 567 @num_coord.setter 571 568 def num_coord(self, v): self.details[-2] = v 572 @property 573 def total_pd(self): return self.details[-3] 574 @total_pd.setter 575 def total_pd(self, v): self.details[-3] = v 576 @property 577 def num_active(self): return self.details[-4] 578 @num_active.setter 579 def num_active(self, v): self.details[-4] = v 569 570 @property 571 def theta_par(self): return self.details[-1] 580 572 581 573 def show(self): … … 638 630 639 631 632 def create_vector_Iq(model_info): 633 """ 634 Define Iq as a vector function if it exists. 635 """ 636 Iq = model_info['Iq'] 637 if callable(Iq) and not getattr(Iq, 'vectorized', False): 638 def vector_Iq(q, *args): 639 """ 640 Vectorized 1D kernel. 641 """ 642 return np.array([Iq(qi, *args) for qi in q]) 643 model_info['Iq'] = vector_Iq 644 645 def create_vector_Iqxy(model_info): 646 """ 647 Define Iqxy as a vector function if it exists, or default it from Iq(). 648 """ 649 Iq, Iqxy = model_info['Iq'], model_info['Iqxy'] 650 if callable(Iqxy) and not getattr(Iqxy, 'vectorized', False): 651 def vector_Iqxy(qx, qy, *args): 652 """ 653 Vectorized 2D kernel. 654 """ 655 return np.array([Iqxy(qxi, qyi, *args) for qxi, qyi in zip(qx, qy)]) 656 model_info['Iqxy'] = vector_Iqxy 657 elif callable(Iq): 658 # Iq is vectorized because create_vector_Iq was already called. 659 def default_Iqxy(qx, qy, *args): 660 """ 661 Default 2D kernel. 662 """ 663 return Iq(np.sqrt(qx**2 + qy**2), *args) 664 model_info['Iqxy'] = default_Iqxy 665 640 666 def create_default_functions(model_info): 641 667 """ … … 643 669 644 670 This only works for Iqxy when Iq is written in python. :func:`make_source` 645 performs a similar role for Iq written in C. 646 """ 647 if callable(model_info['Iq']) and model_info['Iqxy'] is None: 648 partable = model_info['parameters'] 649 if partable.has_2d: 650 raise ValueError("Iqxy model is missing") 651 Iq = model_info['Iq'] 652 def Iqxy(qx, qy, **kw): 653 return Iq(np.sqrt(qx**2 + qy**2), **kw) 654 model_info['Iqxy'] = Iqxy 655 671 performs a similar role for Iq written in C. This also vectorizes 672 any functions that are not already marked as vectorized. 673 """ 674 create_vector_Iq(model_info) 675 create_vector_Iqxy(model_info) # call create_vector_Iq() first 656 676 657 677 def load_kernel_module(model_name):
Note: See TracChangeset
for help on using the changeset viewer.