1
1
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
2
- # Last modified by David J Turner (turne540@msu.edu) 24 /07/2024, 16:16 . Copyright (c) The Contributors
2
+ # Last modified by David J Turner (turne540@msu.edu) 25 /07/2024, 11:04 . Copyright (c) The Contributors
3
3
4
4
import inspect
5
5
import os
@@ -1015,6 +1015,8 @@ def nlls_fit(self, model: BaseModel1D, num_samples: int, show_warn: bool) -> Tup
1015
1015
1016
1016
# Curve fit is a simple non-linear least squares implementation, its alright but fragile
1017
1017
try :
1018
+ print (y_errs )
1019
+ print (lower_bounds , upper_bounds )
1018
1020
fit_par , fit_cov = curve_fit (model .model , rads , y_data , p0 = model .unitless_start_pars , sigma = y_errs ,
1019
1021
absolute_sigma = True , bounds = (lower_bounds , upper_bounds ))
1020
1022
@@ -1031,11 +1033,17 @@ def nlls_fit(self, model: BaseModel1D, num_samples: int, show_warn: bool) -> Tup
1031
1033
warning_str = "Very large parameter uncertainties"
1032
1034
success = False
1033
1035
except RuntimeError as r_err :
1034
- warn ("{}, curve_fit has failed." .format (str (r_err )))
1036
+ warn ("{}, curve_fit has failed." .format (str (r_err )), stacklevel = 2 )
1035
1037
warning_str = str (r_err )
1036
1038
success = False
1037
1039
fit_par = np .full (len (model .model_pars ), np .nan )
1038
1040
fit_par_err = np .full (len (model .model_pars ), np .nan )
1041
+ except ValueError as v_err :
1042
+ warn ("{}, curve_fit has failed." .format (str (v_err )), stacklevel = 2 )
1043
+ warning_str = str (v_err )
1044
+ success = False
1045
+ fit_par = np .full (len (model .model_pars ), np .nan )
1046
+ fit_par_err = np .full (len (model .model_pars ), np .nan )
1039
1047
1040
1048
# Using the parameter values and the covariance matrix I generate parameter distributions to store in the
1041
1049
# model instance.
@@ -2852,8 +2860,8 @@ def view(self, figsize: Tuple = (10, 7), xscale: str = "log", yscale: str = "log
2852
2860
else :
2853
2861
main_leg = main_ax .legend (loc = "upper left" , bbox_to_anchor = (1.01 , 1 ), ncol = 1 , borderaxespad = 0 )
2854
2862
# This makes sure legend keys are shown, even if the data is hidden
2855
- for leg_key in main_leg .legendHandles :
2856
- leg_key .set_visible (True )
2863
+ # for leg_key in main_leg.legendHandles:
2864
+ # leg_key.set_visible(True)
2857
2865
2858
2866
# We specify which axes object needs formatters applied, depends on whether the residual ax is being
2859
2867
# shown or not - slightly dodgy way of checking for a local declaration of the residual axes
@@ -2892,17 +2900,3 @@ def __add__(self, other):
2892
2900
raise TypeError ("You may only add 1D Profiles, 1D Aggregate Profiles, or a list of 1D profiles"
2893
2901
" to this object." )
2894
2902
return BaseAggregateProfile1D (to_combine )
2895
-
2896
-
2897
-
2898
-
2899
-
2900
-
2901
-
2902
-
2903
-
2904
-
2905
-
2906
-
2907
-
2908
-
0 commit comments