-1
I have a problem that I have been trying for days and I can not solve, my intention is to read a file '.txt' that has 3 columns, where the first and the second are the data of the x and y axis, the third corresponds to errors in the measure of y.
I already have a code where I can read one of the files and do the curve_fit
using these errors normally. Here’s an example of the data that works normally:
1.93284302829275 | 1.0000 | 0.0155 |
1.83325572101959 | 0.9980 | 0.0223 |
1.75779600641488 | 1.0128 | 0.0218 |
1.69986720735311 | 0.9922 | 0.0216 |
Below is the command to make the adjustment:
fit = curve_fit(function, dados_x, dados_y, p0 = chute_inicial, sigma = erros_y, absolute_sigma = True)
parameters, covariance = fit
function
is and the function I have to adjust and erro_y
is my array of errors. So far I have no problems, since I can read normally the plotar data and make the adjustment of the same, but all other data are the way:
1.67959191946530 | 1.16013 | |
1.61611329822180 | 1.06712 | |
1.54627784681844 | 0.54685 | |
1.46601679272179 | 0.11073 | |
1.43782539290420 | 0.06403 | |
1.39801033774900 | 0.01811 | 0.003925 |
1.38945284689075 | 0.00903 | 0.002920 |
Where the error column may have missing values, when I try to do the curve_fit
using this data receives the following message:
[1. 1. 1.]
[[inf inf inf inf][inf inf inf inf]
[inf inf inf inf]]
/usr/local/lib/python3.7/dist-Packages/scipy/optimize/minpack.py:808: Optimizewarning: Covariance of the Parameters could not be estimated Category=Optimizewarning)
So I can’t find the parameters to perform the fit, I’d like to know if there’s any solution to that. Thanks to anyone who can help me I’m desperate now.
Dude, without your code it’s hard to give an accurate answer, but you could at the time of reading the lines in that file, when you find lines with the third column missing, set to 0. Or at the time you pass the data to the function check if it contains the 3 values, if not, arrow as 0, and pass 0 to function.
– DimitriFinger