•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 402,806 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,040 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 140 | Replies: 0
![]() |
•
•
Join Date: Jul 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi guys,
I'm quite new to the whole programming schmeal. I have a python program written to generate gaussian graphs. However, I need to obtain the data points from these graphs and put them into a different file. I wanted to know if there is any way I can do this? The data points that I am interested in putting into a separate file are the contained in these lines:
alpha1 = float(l[3]); mean1 = float(l[4]); var1 = float(l[5]); alpha2 = float(l[6]); mean2 = float(l[7]); var2 = float(l[8]); alpha3 = float(l[9]); mean3 =float(l[10]); var3 = float(l[11])
This is the program to generate my gaussians. Can I alter this to just put the data for each graph in a files without also creating graphs?
Thanks a MILLION in advance!!!
I'm quite new to the whole programming schmeal. I have a python program written to generate gaussian graphs. However, I need to obtain the data points from these graphs and put them into a different file. I wanted to know if there is any way I can do this? The data points that I am interested in putting into a separate file are the contained in these lines:
alpha1 = float(l[3]); mean1 = float(l[4]); var1 = float(l[5]); alpha2 = float(l[6]); mean2 = float(l[7]); var2 = float(l[8]); alpha3 = float(l[9]); mean3 =float(l[10]); var3 = float(l[11])
This is the program to generate my gaussians. Can I alter this to just put the data for each graph in a files without also creating graphs?
Thanks a MILLION in advance!!!
# 3 gaussian
dist = [2.75, 3.25, 3.75, 4.25, 4.75, 5.25, 5.75, 6.25, 6.75, 7.25, 7.75, 8.25, 8.75, 9.25, 9.75, 10.25, 10.75, 11.25, 11.75, 12.25, 12.75, 13.25, 13.75, 14.25]
for fname in os.listdir(os.getcwd()):
if (fname.find('gauss_fit_3') != -1 and fname.find('.dat') != -1):
#if (fname == 'gauss_fit_3_GLU_GLN_l5_6.dat'):
f = open(fname)
save = ''
set = 0
for line in f:
if line.find('final score') == 1:
set = 1
else:
if (set == 0):
continue
if (set == 1 ):
save = line
break
f.close()
l = save.split()
alpha1 = float(l[3]); mean1 = float(l[4]); var1 = float(l[5]); alpha2 = float(l[6]); mean2 = float(l[7]); var2 = float(l[8]); alpha3 = float(l[9]); mean3 =float(l[10]); var3 = float(l[11])
name = fname.replace('gauss_fit_3', 'clean_hist_data')
g = open (name)
prob = []
for line in g:
#dist.append(float(line.split()[0])) #constant
prob.append(float(line.split()[1]))
g.close()
graphname = name.replace ("clean_hist_data_", '')
graphname = graphname.replace('.dat', '.fig')
title = graphname.replace ('_', ' ')
#height1_x = (1/sqrt(2.*acos(-1.))/$sigma1_x)
#define height2_x $($alpha2_x/sqrt(2.*acos(-1.))/$sigma2_x)
#define height3_x $($alpha3_x/sqrt(2.*acos(-1.))/$sigma3_x)
#set t=0,14,0.001
#set ft = ($height1_x*exp(-((t - $mean1_x)/(sqrt(2.)*$sigma1_x))**2) +$height2_x*exp(-((t - $mean2_x)/(sqrt(2.)*$sigma2_x))**2) +$height3_x*exp(-((t -$mean3_x)/(sqrt(2.)*$sigma3_x))**2))/(1\
.+$alpha3_x)
height1 = (1/(2.*3.1415927)**0.5)/var1
height2 = (alpha2/(2.*3.1415927)**0.5)/var2
height3 = (alpha3/(2.*3.1415927)**0.5)/var3
cmd = "matlab -nodisplay << EOF %s t = 0:0.001:14; %s bar (%s, %s) %s title ('%s') %s hold on %s gauss = (1/(1+%f)) * (%f* exp(- ((t-%f)/((2^0.5)*%f)).^2) + %f * exp(- ((t-%f)/((2^0.5)*%f\
)).^2) + %f * exp( - ((t-%f)/((2^0.5)*%f)).^2)); %s plot (t,gauss,'color', 'red', 'linewidth', 2) %s hgsave ('%s') %s EOF %s" %('\n','\n', dist, prob, '\n',title, '\n', '\n', alpha3, height1, mean1, var\
1, height2, mean2, var2, height3, mean3, var3, '\n', '\n', graphname, '\n', '\n')
os.system(cmd) Last edited by Tekmaven : Jul 18th, 2008 at 5:35 am. Reason: Code tags
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Reading of Excel
- Next Thread: Backgrounds in python


Linear Mode