@@ -458,7 +458,7 @@ def onSaveAllStats(self, evt=None):
458
458
'# Fitted Array name: %s' % user_opts ['array_name' ],
459
459
'# Model form: %s' % model_desc ,
460
460
'# Baseline form: %s' % user_opts ['baseline_form' ],
461
- '# Energy fit range: [%f, %f]' % (user_opts ['emin ' ], user_opts ['emax ' ]),
461
+ '# Energy fit range: [%f, %f]' % (user_opts ['xmin ' ], user_opts ['xmax ' ]),
462
462
'#--------------------' ]
463
463
464
464
labels = [('Data Set' + ' ' * 25 )[:25 ], 'Group name' , 'n_data' ,
@@ -473,10 +473,10 @@ def onSaveAllStats(self, evt=None):
473
473
if not hasattr (dgroup , 'curvefit' ):
474
474
continue
475
475
try :
476
- pkfit = dgroup .curvefit .fit_history [0 ]
476
+ cvfit = dgroup .curvefit .fit_history [0 ]
477
477
except :
478
478
continue
479
- result = pkfit .result
479
+ result = cvfit .result
480
480
label = dgroup .filename
481
481
if len (label ) < 25 :
482
482
label = (label + ' ' * 25 )[:25 ]
@@ -511,12 +511,12 @@ def onExportFitResult(self, event=None):
511
511
512
512
outfile = FileSave (self , 'Export Fit Result' , default_file = deffile )
513
513
514
- pkfit = self .get_fitresult ()
515
- result = pkfit .result
514
+ cvfit = self .get_fitresult ()
515
+ result = cvfit .result
516
516
if outfile is not None :
517
517
i1 , i2 = get_xlims (dgroup .xplot ,
518
- pkfit .user_options ['emin ' ],
519
- pkfit .user_options ['emax ' ])
518
+ cvfit .user_options ['xmin ' ],
519
+ cvfit .user_options ['xmax ' ])
520
520
x = dgroup .xplot [i1 :i2 ]
521
521
y = dgroup .yplot [i1 :i2 ]
522
522
yerr = None
@@ -743,10 +743,10 @@ def onPanelExposed(self, **kws):
743
743
except :
744
744
pass # print(" Cannot Fill curvefit panel from group ")
745
745
746
- pkfit = getattr (self .larch .symtable , 'curvefit_result' , None )
747
- if pkfit is not None :
746
+ cvfit = getattr (self .larch .symtable , 'curvefit_result' , None )
747
+ if cvfit is not None :
748
748
self .showresults_btn .Enable ()
749
- self .use_modelresult (pkfit )
749
+ self .use_modelresult (cvfit )
750
750
751
751
def onModelPanelExposed (self , event = None , ** kws ):
752
752
pass
@@ -756,14 +756,30 @@ def build_display(self):
756
756
757
757
self .wids = {}
758
758
759
- fsopts = dict (digits = 2 , increment = 1 , size = (125 , - 1 ), with_pin = True )
759
+ # xrange row
760
+ xrpanel = wx .Panel (pan )
761
+ xrsizer = wx .BoxSizer (wx .HORIZONTAL )
762
+ fsopts = dict (parent = xrpanel , digits = 2 , increment = 1 ,
763
+ size = (125 , - 1 ), with_pin = True )
760
764
761
765
curvefit_xmin = self .add_floatspin ('curvefit_xmin' , value = - 1 , ** fsopts )
762
766
curvefit_xmax = self .add_floatspin ('curvefit_xmax' , value = + 1 , ** fsopts )
763
767
764
- self .xrange_choice = Choice (pan , size = (175 , - 1 ),
768
+ self .xrange_choice = Choice (xrpanel , size = (175 , - 1 ),
765
769
choices = ['Full Range' , 'Set Xmin / Xmax' ],
766
770
action = self .onXrangeChoice )
771
+
772
+ self .wids ['show_fitrange' ] = Check (xrpanel , label = 'show?' , default = True ,
773
+ size = (75 , - 1 ), action = self .onPlot )
774
+
775
+ xrsizer .Add (self .xrange_choice , 0 )
776
+ xrsizer .Add (SimpleText (xrpanel , ' X min:' ), 0 )
777
+ xrsizer .Add (curvefit_xmin , 0 )
778
+ xrsizer .Add (SimpleText (xrpanel , ' X max: ' ), 0 )
779
+ xrsizer .Add (curvefit_xmax , 0 )
780
+ xrsizer .Add (self .wids ['show_fitrange' ], 0 )
781
+ pack (xrpanel , xrsizer )
782
+
767
783
self .wids ['curvefit_xmin' ].Disable ()
768
784
self .wids ['curvefit_xmax' ].Disable ()
769
785
self .xrange_choice .SetSelection (0 )
@@ -802,8 +818,6 @@ def build_display(self):
802
818
803
819
self .message = SimpleText (pan , '' )
804
820
805
- opts = dict (default = True , size = (75 , - 1 ), action = self .onPlot )
806
- self .show_fitrange = Check (pan , label = 'show?' , ** opts )
807
821
808
822
opts = dict (default = False , size = (200 , - 1 ), action = self .onPlot )
809
823
@@ -816,18 +830,14 @@ def add_text(text, dcol=1, newrow=True):
816
830
add_text (' Array to fit: ' )
817
831
pan .Add (self .array_choice , dcol = 3 )
818
832
819
- add_text (' X Range : ' )
820
- pan .Add (self . xrange_choice , dcol = 4 )
821
- pan . Add ( self . loadresults_btn )
833
+ add_text ( ' X range : ' )
834
+ pan .Add (xrpanel , dcol = 5 )
835
+
822
836
823
- add_text (' X min/max: ' )
824
- pan .Add (curvefit_xmin )
825
- add_text (' : ' , newrow = False )
826
- pan .Add (curvefit_xmax )
827
- pan .Add (self .show_fitrange )
837
+ pan .Add ((10 , 10 ), newrow = True )
838
+ pan .Add (self .loadresults_btn )
828
839
pan .Add (self .showresults_btn )
829
840
830
- pan .Add ((10 , 10 ))
831
841
832
842
pan .Add (HLine (pan , size = (600 , 2 )), dcol = 6 , newrow = True )
833
843
@@ -908,7 +918,7 @@ def fill_form(self, dat):
908
918
909
919
910
920
self .array_choice .SetStringSelection (dat ['array_desc' ])
911
- self .show_fitrange .Enable (dat ['show_fitrange' ])
921
+ self .wids [ ' show_fitrange' ] .Enable (dat ['show_fitrange' ])
912
922
913
923
def read_form (self ):
914
924
"read for, returning dict of values"
@@ -927,7 +937,7 @@ def read_form(self):
927
937
else :
928
938
form_opts ['xmin' ] = self .wids ['curvefit_xmin' ].GetValue ()
929
939
form_opts ['xmax' ] = self .wids ['curvefit_xmax' ].GetValue ()
930
- form_opts ['show_fitrange' ] = self .show_fitrange .IsChecked ()
940
+ form_opts ['show_fitrange' ] = self .wids [ ' show_fitrange' ] .IsChecked ()
931
941
return form_opts
932
942
933
943
@@ -1245,12 +1255,12 @@ def onLoadFitResult(self, event=None):
1245
1255
1246
1256
self .use_modelresult (dat [1 ])
1247
1257
1248
- def use_modelresult (self , pkfit ):
1258
+ def use_modelresult (self , cvfit ):
1249
1259
for prefix in list (self .fit_components .keys ()):
1250
1260
self .onDeleteComponent (prefix = prefix )
1251
1261
1252
- result = pkfit .result
1253
- bkg_comps = pkfit .user_options ['bkg_components' ]
1262
+ result = cvfit .result
1263
+ bkg_comps = cvfit .user_options ['bkg_components' ]
1254
1264
for comp in result .model .components :
1255
1265
isbkg = comp .prefix in bkg_comps
1256
1266
self .addModel (model = comp .func .__name__ ,
@@ -1269,7 +1279,7 @@ def use_modelresult(self, pkfit):
1269
1279
if wids .minval is not None : wids .minval .SetValue (par .min )
1270
1280
if wids .maxval is not None : wids .maxval .SetValue (par .max )
1271
1281
1272
- self .fill_form (pkfit .user_options )
1282
+ self .fill_form (cvfit .user_options )
1273
1283
1274
1284
1275
1285
def get_xranges (self , x ):
@@ -1387,13 +1397,13 @@ def onFitSelected(self, event=None):
1387
1397
imin = imin , imax = imax ,
1388
1398
user_opts = repr (opts )))
1389
1399
1390
- pkfit = self .larch_get ("curvefit_result" )
1391
- jnl = {'label' : pkfit .label , 'var_names' : pkfit .result .var_names ,
1392
- 'model' : repr (pkfit .result .model )}
1393
- jnl .update (pkfit .user_options )
1400
+ cvfit = self .larch_get ("curvefit_result" )
1401
+ jnl = {'label' : cvfit .label , 'var_names' : cvfit .result .var_names ,
1402
+ 'model' : repr (cvfit .result .model )}
1403
+ jnl .update (cvfit .user_options )
1394
1404
dgroup .journal .add ('curvefit' , jnl )
1395
1405
if igroup == 0 :
1396
- self .autosave_modelresult (pkfit )
1406
+ self .autosave_modelresult (cvfit )
1397
1407
1398
1408
self .subframes ['curvefit_result' ].add_results (dgroup , form = opts ,
1399
1409
larch_eval = self .larch_eval ,
@@ -1445,13 +1455,13 @@ def onFitModel(self, event=None):
1445
1455
user_opts = repr (opts )))
1446
1456
1447
1457
# journal about curvefit_result
1448
- pkfit = self .larch_get ("curvefit_result" )
1449
- jnl = {'label' : pkfit .label , 'var_names' : pkfit .result .var_names ,
1450
- 'model' : repr (pkfit .result .model )}
1451
- jnl .update (pkfit .user_options )
1458
+ cvfit = self .larch_get ("curvefit_result" )
1459
+ jnl = {'label' : cvfit .label , 'var_names' : cvfit .result .var_names ,
1460
+ 'model' : repr (cvfit .result .model )}
1461
+ jnl .update (cvfit .user_options )
1452
1462
dgroup .journal .add ('curvefit' , jnl )
1453
1463
1454
- self .autosave_modelresult (pkfit )
1464
+ self .autosave_modelresult (cvfit )
1455
1465
self .onPlot ()
1456
1466
self .showresults_btn .Enable ()
1457
1467
0 commit comments