@@ -1130,6 +1130,12 @@ def addModel(self, event=None, model=None, prefix=None, isbkg=False, opts=None):
1130
1130
self .models_other .SetSelection (0 )
1131
1131
1132
1132
mod_abbrev = get_model_abbrev (model )
1133
+
1134
+ opts = self .read_form ()
1135
+ dgroup = self .controller .get_group ()
1136
+ has_data = getattr (dgroup , 'yplot' , None ) is not None
1137
+ is_peakmodel = model in ModelChoices ['peaks' ]
1138
+
1133
1139
if prefix is None :
1134
1140
curmodels = ["%s%i_" % (mod_abbrev , i + 1 ) for i in range (1 + len (self .fit_components ))]
1135
1141
for comp in self .fit_components :
@@ -1205,9 +1211,12 @@ def SLabel(label, size=(80, -1), **kws):
1205
1211
SLabel (" Min" , size = (60 , - 1 )),
1206
1212
SLabel (" Max" , size = (60 , - 1 )), SLabel (" Expression" )))
1207
1213
1214
+ if has_data :
1215
+ xdata = getattr (dgroup , 'xplot' , np .arange (2 ))
1216
+ ydata = getattr (dgroup , 'yplot' , np .arange (2 ))
1217
+
1208
1218
parwids = {}
1209
1219
parnames = sorted (minst .param_names )
1210
-
1211
1220
for a in minst ._func_allargs :
1212
1221
pname = "%s%s" % (prefix , a )
1213
1222
if (pname not in parnames and
@@ -1218,14 +1227,27 @@ def SLabel(label, size=(80, -1), **kws):
1218
1227
for pname in parnames :
1219
1228
sname = pname [len (prefix ):]
1220
1229
hints = minst .param_hints .get (sname , {})
1230
+ value = 0.0
1231
+ if is_peakmodel and 'sigma' in pname :
1232
+ value = 1.0
1233
+ if has_data :
1234
+ value = max (0.5 , 0.1 * (opts ['ehi' ] - opts ['elo' ]))
1235
+ elif is_peakmodel and 'center' in pname :
1236
+ value = 1.0
1237
+ if has_data :
1238
+ value = int ((opts ['ehi' ] + opts ['elo' ])/ 2.0 )
1239
+ elif is_peakmodel and 'ampl' in pname :
1240
+ value = 1.0
1241
+ if has_data :
1242
+ value = ydata .ptp ()
1243
+ if 'value' in hints :
1244
+ value = hints ['value' ]
1221
1245
1222
- par = Parameter (name = pname , value = 0 , vary = True )
1246
+ par = Parameter (name = pname , value = value , vary = True )
1223
1247
if 'min' in hints :
1224
1248
par .min = hints ['min' ]
1225
1249
if 'max' in hints :
1226
1250
par .max = hints ['max' ]
1227
- if 'value' in hints :
1228
- par .value = hints ['value' ]
1229
1251
if 'expr' in hints :
1230
1252
par .expr = hints ['expr' ]
1231
1253
0 commit comments