Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Using curve_fit to optimize function (TypeError)
Post: RE: Using curve_fit to optimize function (TypeErro...
(Aug-30-2021, 05:11 AM)Laplace12 Wrote: (Aug-29-2021, 07:38 PM)Larz60+ Wrote: you haven't passed any arguments to function dy
You mean x, a, b? a and b I wish to get optimized by *popt1, do I stil... |
|
Laplace12 |
General Coding Help |
4 |
2,454 |
Aug-30-2021, 07:40 AM |
|
|
Thread: Using curve_fit to optimize function (TypeError)
Post: RE: Using curve_fit to optimize function (TypeErro...
(Aug-29-2021, 07:38 PM)Larz60+ Wrote: you haven't passed any arguments to function dy
You mean x, a, b? a and b I wish to get optimized by *popt1, do I still need to make some guess about the values... |
|
Laplace12 |
General Coding Help |
4 |
2,454 |
Aug-30-2021, 05:11 AM |
|
|
Thread: Using curve_fit to optimize function (TypeError)
Post: Using curve_fit to optimize function (TypeError)
Hey!
I have some experimental data that I know follows a certain function. My aim is to fit a function (dy) to the data points and get Python to return the offset values.
import math
import numpy a... |
|
Laplace12 |
General Coding Help |
4 |
2,454 |
Aug-29-2021, 05:05 PM |
|
|
Thread: Returning values from Gaussian fitting
Post: Returning values from Gaussian fitting
Hey,
I'm trying to fit a Gaussian function to some data, but I want to return the 'center' and 'width' values and print them. The code returns a ValueError:
import numpy as np
import matplotlib.pypl... |
|
Laplace12 |
General Coding Help |
0 |
1,549 |
Aug-05-2021, 08:09 AM |
|
|
Thread: Plotting simple graph (AttributeError)
Post: Plotting simple graph (AttributeError)
Hey,
I'm trying to plot energy as a function of My. I want to plot the function for values of n between 1-10, but the code returns an AttributeError. I tried putting the My value straight into the eq... |
|
Laplace12 |
General Coding Help |
0 |
1,344 |
Jul-28-2021, 10:58 AM |
|
|
Thread: Fit np.polyfit to data points
Post: RE: Fit np.polyfit to data points
(Jul-07-2021, 06:36 AM)Gribouillis Wrote: You may need to call the poly1d perhaps
plt.plot(xs1, np.poly1d(np.polyfit(xs1, ys1, 2))(xs1),
label='0')
Ah, thanks! Now it plots points with no ... |
|
Laplace12 |
General Coding Help |
3 |
1,588 |
Jul-07-2021, 06:42 AM |
|
|
Thread: Fit np.polyfit to data points
Post: Fit np.polyfit to data points
Hey! Trying to get polyfit working. I want to fit a 2nd order polynomial to some data points, but the code returns no plot. All x10, x11, y10, etc. values have been manually pointed out from data file... |
|
Laplace12 |
General Coding Help |
3 |
1,588 |
Jul-07-2021, 06:34 AM |
|
|
Thread: [Solved] Plotting data from txt file
Post: RE: Plotting data from txt file
I've now changed the composition of the values so that I have everything in a list. Now what I'd have to do is stack every 8th value into a column somehow, if that's possible, or create a loop to calc... |
|
Laplace12 |
General Coding Help |
1 |
1,780 |
Jul-06-2021, 07:14 AM |
|
|
Thread: [Solved] Plotting data from txt file
Post: [Solved] Plotting data from txt file
Hey! I'm trying to plot a text file that looks like this:
#0 0.4000 0.1485 2.1926 Fixed 0.0195 0.0299 64.9854 11.2706 23.7440 1.4814 1.2203 0.3871 42.1810 0.0664
#1 ... |
|
Laplace12 |
General Coding Help |
1 |
1,780 |
Jul-04-2021, 02:14 PM |
|
|
Thread: [Solved] Reading every nth line into a column from txt file
Post: RE: Reading every nth line into a column from txt ...
(Jun-28-2021, 11:20 PM)Yoriz Wrote: output
Output:CA50_40_ref_data2101_E04_spec0-70 #0
Lifetimes (ns) : 0.4000 0.1250 2.0446
Std deviations : Fixed Fix... |
|
Laplace12 |
General Coding Help |
7 |
5,144 |
Jun-29-2021, 09:17 AM |
|
|
Thread: [Solved] Reading every nth line into a column from txt file
Post: RE: Reading every nth line into a column from txt ...
(Jun-28-2021, 01:20 PM)snippsat Wrote: What is the output you want from this?
I can not see why you look for Lifetime,Std deviations...ect in this.
Are you making this file?
When put a Python list [... |
|
Laplace12 |
General Coding Help |
7 |
5,144 |
Jun-28-2021, 06:47 PM |
|
|
Thread: [Solved] Reading every nth line into a column from txt file
Post: RE: Reading every nth line into a column from txt ...
(Jun-28-2021, 10:54 AM)snippsat Wrote: How dos the original file look it's properly a better way,but can not advice anything without a sample of original file.
Hey, it looks like this:
#0
0.4000 0.... |
|
Laplace12 |
General Coding Help |
7 |
5,144 |
Jun-28-2021, 12:18 PM |
|
|
Thread: [Solved] Reading every nth line into a column from txt file
Post: [Solved] Reading every nth line into a column from...
Hey!
I have a text file that I want to sort out. I've coded this and tried dataframe, but that only prints the last line. The code I have now is this, producing the txt file:
with open(output) as f... |
|
Laplace12 |
General Coding Help |
7 |
5,144 |
Jun-28-2021, 09:47 AM |
|
|
Thread: IndexError: list index out of range
Post: IndexError: list index out of range
Working with a data file to simplify it - my aim is to get the stuff in the file in columns, and I've started with splitting and printing only the necessary lines, I'll still have to sort them out int... |
|
Laplace12 |
General Coding Help |
1 |
2,186 |
Jun-22-2021, 10:12 AM |
|
|
Thread: [Solved] Trying to read specific lines from a file
Post: RE: Trying to read specific lines from a file
(Jun-21-2021, 10:02 AM)snippsat Wrote: (Jun-21-2021, 07:55 AM)Laplace12 Wrote: Alright, I now figured I can maybe try to iterate n and then loop over the lines I want:I still hard-coded lines as ... |
|
Laplace12 |
General Coding Help |
7 |
3,499 |
Jun-21-2021, 11:15 AM |
|
|
Thread: [Solved] Trying to read specific lines from a file
Post: RE: Trying to read specific lines from a file
Alright, I now figured I can maybe try to iterate n and then loop over the lines I want:
r = range(1, 71)
n = iter(r)
with open('file') as fp:
lines = fp.readlines()
lines_needed = [35*n, ... |
|
Laplace12 |
General Coding Help |
7 |
3,499 |
Jun-21-2021, 07:55 AM |
|
|
Thread: [Solved] Trying to read specific lines from a file
Post: RE: Trying to read specific lines from a file
(Jun-21-2021, 07:30 AM)buran Wrote: Instead of hard-coded line numbers it will be much better to parse the file. Based on what you show it looks pretty trivial to do so.
Thanks for the tip! I've onl... |
|
Laplace12 |
General Coding Help |
7 |
3,499 |
Jun-21-2021, 07:36 AM |
|
|
Thread: [Solved] Trying to read specific lines from a file
Post: RE: Trying to read specific lines from a file
(Jun-18-2021, 02:17 PM)Larz60+ Wrote: something like:
recs_needed = [0, 24, 72, 99]
with open('myfile') as fp:
lines = fp.read()
for n, line in enumerate(lines):
if n in recs_needed:
... |
|
Laplace12 |
General Coding Help |
7 |
3,499 |
Jun-21-2021, 07:26 AM |
|
|
Thread: [Solved] Trying to read specific lines from a file
Post: [Solved] Trying to read specific lines from a file
Hey,
I'm struggling with a simple code. I want to extract certain lines from data files. The data files have up to a 100 times datasets after each other, so basically I want to read the same lines f... |
|
Laplace12 |
General Coding Help |
7 |
3,499 |
Jun-18-2021, 11:51 AM |
|
|
Thread: [Solved] TypeError when calling function
Post: RE: TypeError when calling function
(Jun-16-2021, 01:54 PM)BashBedlam Wrote: The gaussian () function requires five parameters. On line 26/27 you call it with only four.
Oh man, I should've realized this **biggrin** the original gaus... |
|
Laplace12 |
General Coding Help |
2 |
2,832 |
Jun-16-2021, 02:46 PM |