@@ -94,15 +94,15 @@ def fit_lorentz(x,guess=None,pos_int_override=False,silent=False):
9494 except RuntimeError :
9595 if not silent :
9696 print ("Fit failed to converge" )
97- retval = xr .DataArray ( data = np .nan ,coords = x . coords ).to_dataset (name = 'intensity' )
98- retval ['pos' ] = xr .DataArray ( data = np .nan ,coords = x . coords )
99- retval ['width' ] = xr .DataArray ( data = np .nan ,coords = x . coords )
97+ retval = xr .full_like ( x , np .nan , dtype = float ).to_dataset (name = 'intensity' )
98+ retval ['pos' ] = xr .full_like ( x , np .nan , dtype = float )
99+ retval ['width' ] = xr .full_like ( x , np .nan , dtype = float )
100100 return retval
101101 if not silent :
102102 print (f"Fit completed, coeff = { coeff } " )
103- retval = xr .DataArray ( data = coeff [0 ],coords = x . coords ).to_dataset (name = 'intensity' )
104- retval ['pos' ] = xr .DataArray ( data = coeff [1 ],coords = x . coords )
105- retval ['width' ] = xr .DataArray ( data = coeff [2 ],coords = x . coords )
103+ retval = xr .full_like ( x , coeff [0 ], dtype = float ).to_dataset (name = 'intensity' )
104+ retval ['pos' ] = xr .full_like ( x , coeff [1 ], dtype = float )
105+ retval ['width' ] = xr .full_like ( x , coeff [2 ], dtype = float )
106106 return retval
107107def fit_lorentz_bg (x ,guess = None ,pos_int_override = False ,silent = False ):
108108 '''
@@ -131,17 +131,17 @@ def fit_lorentz_bg(x,guess=None,pos_int_override=False,silent=False):
131131 except RuntimeError :
132132 if not silent :
133133 print ("Fit failed to converge" )
134- retval = xr .DataArray ( data = np .nan ,coords = x . coords ).to_dataset (name = 'intensity' )
135- retval ['pos' ] = xr .DataArray ( data = np .nan ,coords = x . coords )
136- retval ['width' ] = xr .DataArray ( data = np .nan ,coords = x . coords )
137- retval ['bg' ] = xr .DataArray ( data = np .nan ,coords = x . coords )
134+ retval = xr .full_like ( x , np .nan , dtype = float ).to_dataset (name = 'intensity' )
135+ retval ['pos' ] = xr .full_like ( x , np .nan , dtype = float )
136+ retval ['width' ] = xr .full_like ( x , np .nan , dtype = float )
137+ retval ['bg' ] = xr .full_like ( x , np .nan , dtype = float )
138138 return retval
139139 if not silent :
140140 print (f"Fit completed, coeff = { coeff } " )
141- retval = xr .DataArray ( data = coeff [0 ],coords = x . coords ).to_dataset (name = 'intensity' )
142- retval ['pos' ] = xr .DataArray ( data = coeff [1 ],coords = x . coords )
143- retval ['width' ] = xr .DataArray ( data = coeff [2 ],coords = x . coords )
144- retval ['bg' ] = xr .DataArray ( data = coeff [3 ],coords = x . coords )
141+ retval = xr .full_like ( x , coeff [0 ], dtype = float ).to_dataset (name = 'intensity' )
142+ retval ['pos' ] = xr .full_like ( x , coeff [1 ], dtype = float )
143+ retval ['width' ] = xr .full_like ( x , coeff [2 ], dtype = float )
144+ retval ['bg' ] = xr .full_like ( x , coeff [3 ], dtype = float )
145145 return retval
146146
147147def fit_cos_anisotropy (data ,qL ,qU ,qspacing ,Enlist ,ChiL ,ChiU ,binnumber ,Chilim ):
@@ -329,4 +329,4 @@ def fit_cos(x_data, y_data):
329329 Ani_unc = 0
330330 Chisq = 100
331331
332- return params , Ani , Ani_unc , Chisq
332+ return params , Ani , Ani_unc , Chisq
0 commit comments