Changeset ed8fa6a3 in sasview for fittingview/src/sans/perspectives
- Timestamp:
- Dec 21, 2011 9:18:23 AM (13 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:
- 491d0fc
- Parents:
- 6e01f06
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitting.py
r6e01f06 red8fa6a3 267 267 textdial.write_string(fname, name1, name2) 268 268 textdial.compile_file(fname) 269 270 page = self.fit_panel.get_current_page() 271 temp = self.fit_panel.reset_pmodel_list() 272 if temp: 273 page.model_list_box = temp 274 current_val = page.formfactorbox.GetValue() 275 pos = page.formfactorbox.GetSelection() 276 page._show_combox_helper() 277 page.formfactorbox.SetSelection(pos) 278 page.formfactorbox.SetValue(current_val) 269 self.update_custom_combo() 279 270 except: 280 271 raise … … 287 278 textdial.Destroy() 288 279 289 280 def update_custom_combo(self): 281 """ 282 Update custom model list in the fitpage combo box 283 """ 284 try: 285 temp = self.fit_panel.reset_pmodel_list() 286 if temp: 287 # Set the new custom model list for all fit pages 288 for uid, page in self.fit_panel.opened_pages.iteritems(): 289 if hasattr(page, "formfactorbox"): 290 page.model_list_box = temp 291 current_val = page.formfactorbox.GetValue() 292 pos = page.formfactorbox.GetSelection() 293 page._show_combox_helper() 294 page.formfactorbox.SetSelection(pos) 295 page.formfactorbox.SetValue(current_val) 296 except: 297 pass 298 299 290 300 def set_edit_menu(self, owner): 291 301 """ -
fittingview/src/sans/perspectives/fitting/plugin_models/polynominal5.py
r7c8d3093 red8fa6a3 7 7 """ 8 8 from sans.models.pluginmodel import Model1DPlugin ##DO NOT CHANGE THIS LINE!!! 9 10 ## FOR MORE INFORMATION CHECK http://docs.python.org/library/math.html 11 ## AND http://www.scipy.org/Numpy_Functions_by_Category 9 12 import math ##DO NOT CHANGE THIS LINE!!! 10 import numpy ##DO NOT CHANGE THIS LINE!!! 11 12 ##PLEASE READ COMMENTS CAREFULLY !!! COMMENT ARE IN CAPITAL LETTERS AND AFTER ## 13 ## THESE COMMENTS ARE THERE TO GUIDE YOU. YOU CAN REMOVE THEM ONLY WHEN YOU ARE 14 ## CONFORTABLE ENOUGH WITH OUR MODEL PLUGIN OPTION 15 13 import numpy ##DO NOT CHANGE THIS LINE!!! 16 14 17 15 ## <----- SIGN DEFINES WHERE YOU CAN MODIFY THE CODE … … 25 23 """ 26 24 ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " " 27 ## TO RENAME YOUR MODEL 28 name = "polynomial5" ## <----- NAME OF THE MODEL25 ## TO RENAME YOUR MODEL: THIS NAME IS WHAT YOU SEE ON GUI. 26 name = "polynomial5" ## <----- NAME OF THE MODEL 29 27 30 28 def __init__(self): ##DO NOT CHANGE THIS LINE!!! … … 34 32 Model1DPlugin.__init__(self, name=self.name) ##DO NOT CHANGE THIS LINE!!! 35 33 36 ## EDIT PARAMETERS' NAMES AND VALUE 37 ## DELETE MODIFIABLE LINE HERE WILL REDUCE THE NUMBER OF PARAMETERS 38 self.params = {} ##DO NOT CHANGE THIS LINE!!! 39 40 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 41 ## YOU CAN ALSO DELETE THIS LINE 42 self.params['A'] = 0.0 ## <----- 43 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 44 ## YOU CAN ALSO DELETE THIS LINE 45 self.params['B'] = 10.0 ## <----- 46 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 47 ## YOU CAN ALSO DELETE THIS LINE 48 self.params['C'] = 0.0 ## <----- 49 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 50 ## YOU CAN ALSO DELETE THIS LINE 51 self.params['D'] = 0.0 ## <----- 52 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 53 ## YOU CAN ALSO DELETE THIS LINE 54 self.params['E'] = 0.0 ## <----- 55 ## YOU CAN MODIFY THELINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 56 ## YOU CAN ALSO DELETE THIS LINE 57 self.params['F'] = 0.0 ## <----- 58 59 ## STORING PARAMETERS [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 60 self.details = {} ##DO NOT CHANGE THIS LINE!!! 61 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 62 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 63 self.details['A'] = ['', None, None] ## <----- 64 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 65 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 66 self.details['B'] = ['', None, None] ## <----- 67 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 68 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 69 self.details['C'] = ['', None, None] ## <----- 70 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 71 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 72 self.details['D'] = ['', None, None] ## <----- 73 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 74 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 75 self.details['E'] = ['', None, None] ## <----- 76 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 77 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 78 self.details['F'] = ['', None, None] ## <----- 79 ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """ """ ONLY!!!! 80 self.description = """ 81 F(x) where F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5 82 """ ## <----- 34 ## HERE WE DEFINE THE PARAM NAME AND ITS INITIAL VALUE 35 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER 36 self.params['A'] = 0.1 ## <----- 37 self.params['B'] = 10.0 ## <----- 38 self.params['C'] = 0.0 ## <----- 39 self.params['D'] = 0.0 ## <----- 40 self.params['E'] = 0.0 ## <----- 41 self.params['F'] = 0.0 ## <----- 42 43 ## DEFINE DEFAULT DETAILS 44 self.set_details() ##DO NOT DELETE OR CHANGE THIS LINE!!! 45 46 ## IN THIS EXAMPLE THE FUNTION IS: 47 ## F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5 83 48 84 49 def function(self, x = 0.0): ##DO NOT CHANGE THIS LINE!!! … … 88 53 :return: function value 89 54 """ 90 ## ADD YOUR FUNCTION HERE. 91 ## REUSE THE PARAMETERS DEFINED PREVIOUSLY TO WRITE YOUR FUNCTION. 92 93 ## IN THIS EXAMPLE THE FUNTION IS: 94 ## F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5 95 96 ## NOTE: pow IS A FUNCTION IMPORTED FROM PYTHON MATH LIBRARY 97 ## FOR MORE INFORMATION CHECK http://docs.python.org/library/math.html 98 ## OTHER FUNCTIONS ARE ALSO 99 ### AVAILABLE http://www.scipy.org/Numpy_Functions_by_Category 100 ## numpy FUNCTIONS ARE FOR EXPERT USER 101 102 55 ## DEFINE YOUR FUNCTION HERE. 103 56 ## YOU CAN ERASE EVERYTHING BELLOW FOR YOUR OWN FUNCTION 104 #Redefine parameters as local parameters 57 #Redefine parameters as local parameters, or skip and use long name 105 58 a = self.params['A'] ## <----- 106 59 b = self.params['B'] ## <----- … … 108 61 d = self.params['D'] ## <----- 109 62 e = self.params['E'] ## <----- 110 f = self.params['F'] 63 f = self.params['F'] ## <----- 111 64 112 65 ##THIS OUR FUNCTION TEMPLATE 113 poly = a + b *x + c*math.pow(x,2) + d*math.pow(x,3) \114 + e*math.pow(x,4) +f*math.pow(x,5)## <-----66 poly = a + b * x + c * math.pow(x,2) + d * math.pow(x,3) \ 67 + e * math.pow(x,4) + f * math.pow(x,5) ## <----- 115 68 69 #(Just note: In Python, indentation defines the belongings 70 # of 'if', 'for', and so on..) 116 71 #(lim x --> 0) 117 #(Just note: In Python, indentation defines the belongings of 'if', 'for', and so on..) 118 if x == 0: ## <----- 72 if x == 0: ## <----- 119 73 result = a ## <----- 120 74 else: ## <----- 121 result = poly ## <-----75 result = poly ## <----- 122 76 123 return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!!77 return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 124 78 125 ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!! 79 ############################################################################### 80 ## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!! 126 81 if __name__ == "__main__": 127 82 m= Model() -
fittingview/src/sans/perspectives/fitting/plugin_models/sph_bessel_jn.py
r7c8d3093 red8fa6a3 54 54 self.params['n'] = 1 ## <----- 55 55 56 ## STORING PARAMETERS [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 57 self.details = {} ##DO NOT CHANGE THIS LINE!!! 58 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 59 ## ' ', TWO OTHER NUMBESR TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 60 self.details['C'] = ['',None, None] ## <----- 61 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 62 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 63 self.details['A'] = ['', None, None] ## <----- 64 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 65 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 66 self.details['B'] = ['', None, None] ## <----- 67 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 68 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 69 self.details['D'] = ['', None, None] ## <----- 70 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 71 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 72 self.details['n'] = ['', None, None] ## <----- 73 56 ## DEFINE DEFAULT DETAILS 57 self.set_details() ##DO NOT DELETE OR CHANGE THIS LINE!!! 58 74 59 ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """ """ ONLY!!!! 75 60 self.description = """ … … 111 96 #(Just note: In Python, indentation defines the belongings of 'if', 'for', and so on..) 112 97 input = a * x + b 113 # sph_out and _ are in array from scipy upto n'th order 98 # sph_out and _ are in array types from scipy upto n'th order 99 # where _ is not used for this function. 114 100 sph_out, _ = scipy.special.sph_jn(n, input) 115 101 # Take only n'th value … … 117 103 118 104 return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 119 105 106 ############################################################################### 120 107 ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!! 121 108 if __name__ == "__main__": -
fittingview/src/sans/perspectives/fitting/plugin_models/sum_Ap1_1_Ap2.py
r7c8d3093 red8fa6a3 2 2 import copy 3 3 from sans.models.pluginmodel import Model1DPlugin 4 # Possible model names4 # Available model names for this sum model 5 5 """ 6 6 BCCrystalModel, BEPolyelectrolyte, BarBellModel, BinaryHSModel, BroadPeakModel, … … 18 18 TwoLorentzianModel, TwoPowerLawModel, VesicleModel 19 19 """ 20 ## This is DIFFERENT from the Easy Custom Sum(p1 + p2)20 ## This model is DIFFERENT from the Easy Custom Sum(p1 + p2) 21 21 ## by definition of the scale factor ***************************************** 22 22 # … … 28 28 29 29 #####DO NOT CHANGE ANYTHING BELOW THIS LINE 30 #####------------------------------------------------------------------------ 30 #####--------------------------------------------------------------------------- 31 31 class Model(Model1DPlugin): 32 32 """ … … 379 379 ( p_model1.name, p_model2.name ) 380 380 self.description += description 381 381 382 ### FOR TEST 382 383 if __name__ == "__main__": 383 384 m1= Model() 384 #m1.setParam("p1_scale", 25)385 #m1.setParam("p1_length", 1000)386 #m1.setParam("p2_scale", 100)387 #m1.setParam("p2_rg", 100)388 385 out1 = m1.runXY(0.01) 389 390 386 m2= Model() 391 #m2.p_model1.setParam("scale", 25)392 #m2.p_model1.setParam("length", 1000)393 #m2.p_model2.setParam("scale", 100)394 #m2.p_model2.setParam("rg", 100)395 387 out2 = 0.5 * m2.p_model1.runXY(0.01) + 0.5 * m2.p_model2.runXY(0.01) 396 388 print "Testing at Q = 0.01:" -
fittingview/src/sans/perspectives/fitting/plugin_models/sum_p1_p2.py
r7c8d3093 red8fa6a3 2 2 import copy 3 3 from sans.models.pluginmodel import Model1DPlugin 4 # Possible model names4 # Available model names for this sum model 5 5 """ 6 6 BCCrystalModel, BEPolyelectrolyte, BarBellModel, BinaryHSModel, BroadPeakModel, … … 27 27 28 28 #####DO NOT CHANGE ANYTHING BELOW THIS LINE 29 #####------------------------------------------------------------------------ 29 #####--------------------------------------------------------------------------- 30 30 class Model(Model1DPlugin): 31 31 """ -
fittingview/src/sans/perspectives/fitting/plugin_models/testmodel.py
r7c8d3093 red8fa6a3 48 48 self.params['C'] = 10.0 ## <----- 49 49 50 ## STORING PARAMETERS [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 51 self.details = {} ##DO NOT CHANGE THIS LINE!!! 52 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 53 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 54 self.details['A'] = ['', -1e16, 1e16] ## <----- 55 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 56 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 57 self.details['B'] = ['', -1e16, 1e16] ## <----- 58 ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 59 ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE 60 self.details['C'] = ['', -1e16, 1e16] ## <----- 50 ## DEFINE DEFAULT DETAILS 51 self.set_details() ##DO NOT DELETE OR CHANGE THIS LINE!!! 52 61 53 ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """ """ ONLY!!!! 62 self.description = "F(x)=A+Bcos(2x)+Csin(2x) " ## <-----54 self.description = "F(x)=A+Bcos(2x)+Csin(2x) " ## <----- 63 55 64 56 def function(self, x = 0.0): ##DO NOT CHANGE THIS LINE!!!
Note: See TracChangeset
for help on using the changeset viewer.