Changeset 79ac6f8 in sasview for sansmodels/src/sans/models/dispersion_models.py
- Timestamp:
- Jun 4, 2010 5:04:49 PM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 5062bbf
- Parents:
- 7116b6e0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/dispersion_models.py
rc9aa125 r79ac6f8 1 """2 This software was developed by the University of Tennessee as part of the3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)4 project funded by the US National Science Foundation.5 1 6 If you use DANSE applications to do scientific research that leads to 7 publication, we ask that you acknowledge the use of the software with the 8 following sentence: 9 10 "This work benefited from DANSE software developed under NSF award DMR-0520547." 11 12 copyright 2008, University of Tennessee 13 """ 2 ################################################################################ 3 #This software was developed by the University of Tennessee as part of the 4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 #project funded by the US National Science Foundation. 6 # 7 #If you use DANSE applications to do scientific research that leads to 8 #publication, we ask that you acknowledge the use of the software with the 9 #following sentence: 10 # 11 #"This work benefited from DANSE software developed under NSF award DMR-0520547." 12 # 13 #copyright 2008, University of Tennessee 14 ################################################################################ 14 15 15 16 """ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 17 Class definitions for python dispersion model for 18 model parameters. These classes are bridges to the C++ 19 dispersion object. 20 21 The ArrayDispersion class takes in numpy arrays only. 22 23 Usage: 24 These classes can be used to set the dispersion model of a SANS model 25 parameter: 26 27 cyl = CylinderModel() 28 cyl.set_dispersion('radius', GaussianDispersion()) 29 30 31 After the dispersion model is set, you can access it's 32 parameter through the dispersion dictionary: 33 34 cyl.dispersion['radius']['width'] = 5.0 35 36 :TODO: For backward compatibility, the model parameters are still kept in 36 37 a dictionary. The next iteration of refactoring work should involve moving 37 38 away from value-based parameters to object-based parameter. We want to … … 39 40 dictionaries into a single dictionary of parameter objects that hold the 40 41 complete information about the parameter (units, limits, dispersion model, etc...). 41 42 42 43 43 44 """ … … 48 49 class DispersionModel: 49 50 """ 50 51 51 Python bridge class for a basic dispersion model 52 class with a constant parameter value distribution 52 53 """ 53 54 def __init__(self): … … 56 57 def set_weights(self, values, weights): 57 58 """ 58 59 Set the weights of an array dispersion 59 60 """ 60 61 message = "set_weights is not available for DispersionModel.\n" … … 64 65 class GaussianDispersion(DispersionModel): 65 66 """ 66 67 67 Python bridge class for a dispersion model based 68 on a Gaussian distribution. 68 69 """ 69 70 def __init__(self): … … 84 85 """ 85 86 def __init__(self): 87 """ 88 """ 86 89 self.cdisp = c_models.new_schulz_model() 87 90 88 91 def set_weights(self, values, weights): 89 92 """ 90 93 Set the weights of an array dispersion 91 94 """ 92 95 message = "set_weights is not available for SchulzDispersion.\n" … … 96 99 class LogNormalDispersion(DispersionModel): 97 100 """ 98 99 101 Python bridge class for a dispersion model based 102 on a Log Normal distribution. 100 103 """ 101 104 def __init__(self): … … 104 107 def set_weights(self, values, weights): 105 108 """ 106 109 Set the weights of an array dispersion 107 110 """ 108 111 message = "set_weights is not available for LogNormalDispersion.\n" … … 112 115 class ArrayDispersion(DispersionModel): 113 116 """ 114 115 116 117 117 Python bridge class for a dispersion model based on arrays. 118 The user has to set a weight distribution that 119 will be used in the averaging the model parameter 120 it is applied to. 118 121 """ 119 122 def __init__(self): … … 122 125 def set_weights(self, values, weights): 123 126 """ 124 Set the weights of an array dispersion 125 Only accept numpy arrays. 126 @param values: numpy array of values 127 @param weights: numpy array of weights for each value entry 127 Set the weights of an array dispersion 128 Only accept numpy arrays. 129 130 :param values: numpy array of values 131 :param weights: numpy array of weights for each value entry 132 128 133 """ 129 134 if len(values) != len(weights):
Note: See TracChangeset
for help on using the changeset viewer.