Help with python script for NMR

2016-03-27 Thread mohamadmaaz5
Hello there,
I found a python script in a scientific article that enables a simple 
calculation on an NMR spectrum.
I have no experience in programming and i would appreciate it if i can 
communicate with someone who can write this script and send it to me by mail in 
py format. It's a short script but i keep making alot of mistaken and it fails 
every time.
Anyone's interested in helping me ?
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python script for NMR

2016-03-27 Thread mohamadmaaz5
On Sunday, March 27, 2016 at 4:50:01 PM UTC+2, Joel Goldstick wrote:
> On Sun, Mar 27, 2016 at 10:38 AM,  wrote:
> 
> > Hello there,
> > I found a python script in a scientific article that enables a simple
> > calculation on an NMR spectrum.
> > I have no experience in programming and i would appreciate it if i can
> > communicate with someone who can write this script and send it to me by
> > mail in py format. It's a short script but i keep making alot of mistaken
> > and it fails every time.
> > Anyone's interested in helping me ?
> > Thanks
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> 
> copy the code here.  You will get help, but people don't generally write
> programs for others here
> 
> -- 
> Joel Goldstick
> http://joelgoldstick.com/ 
> http://cc-baseballstats.info/

this is the script. the thing is that i have zero experience in writing and i 
cant find the error. all i need is to embed this script to perfome a relatively 
simple calculation on a spectra. hope anyone can help. thanks

#! /usr /bin/envpython
#encoding:utf- 8
i m p o r tnmrtec . nmrNotebook . c o n t r o l l e r . C o n t r o l l e r as 
Cont
i m p o r tnmrtec . u t i l as u t i l
i m p o r tnmrtec . nmrNotebook . model . common .nmrCommon as nmrcom
c l a s sBarycentre :
"""
computesthebarycenterofeach
definedr e c t a n g l eanddeducesthe
p o l y d i s p e r s i t yindexofthes o l u t i o n
"""
d e fi n i t( s e l f ) :
"""
i n i t i a l i z e sandgetthei n t e g r a t i o ncoo rdin ates
"""
df =1.86#tobechangedf o reachtypeof...
... molecule
f r o mNNBlibimportDialogText , l i s t O f R e c t a n g l e s
s e l f . d a t a = NNB . l o a d C u r r e n t D a t a ( )
i f( getdim () != 2 ) :
s e l f . die (" Tobeappliedon2Donly" )
i flen ( listOfRectangles () ) == 1 :
s e l f . die (" Youmustaddarectangletodefineazoomregion. " )
i flen ( listOfRectangles () )>2 :
s e l f . die (" expectedtwozoomregion. %dzoomregionsweredefined. " % ...
...len ( listOfRectangles () ) )
f o riin[ 0 , 1 ] :
indexRect = listOfRectangles () [ i ]
dim (2)
s e l f . F1Left = int ( indexRect [ 0 ] )
s e l f . F1Right = int ( indexRect [ 2 ] )
s e l f . F2Left = int ( indexRect [ 1 ] )
s e l f . F2Right = int ( indexRect [ 3 ] )
i fi==0 :
b = s e l f . pointToDamping ( s e l f . barycenter () )
b = b* *(- df )
else:
a = s e l f . pointToDamping ( s e l f . barycenter () )
a = a * *(- df )
ip=a/b
i fip<1.0:
ip= 1/ ip
r e s u l t=" p o l y d i s p e r s i t yindex: %s" %ip
DialogText (" Resultat" , r e s u l t )
#---
defpointToDamping ( s e l f , value ) :
" " "
p o i n t T o D a m p i n gc o n v e r t sp o i n t su n i t si n t od i f f u 
s i o nu n i t s
"""
c = Cont . getCurrentControllerDeDocument ( )
f o l d = c . getCurrentNMRFolder ( )
nsa = f o l d . getNNBNMRSpectrum ( ) . getAxisF ( 1 )
p r i n tvalue
newdamping = u t i l . NMRUnitToolKit . pointToUnit (nmrcom . NMRUnit . ...
...UNITDAMPING, nsa , value )
r e t u r nnewdamping
#---
d e fbarycenter ( s e l f ) :
"""
r e a l i z ethei n t e g r a t i o noverthei n t e g r a t i o nzones 
(obtainedati n i t i a l i z a t i o n)
"""
#i n i t i a l i s a t i o ndud a t a b u f f e razero
dim ( 1 )
zero ( )
put (" data" )
#onmetl apremierecolonne
dim ( 2 )
c o l ( i n t ( s e l f . F2Left ) )
dim ( 1 )
put (" data" )
f o rcolumninrange ( s e l f . F2Left +1, s e l f . F2Right +1) :
dim ( 2 )
c o l ( i n t ( column ) )
dim ( 1 )
a d d d a t a ( )
p u t (" data" )
dim(1)
get (" data" )
m=0
n=0
f o riinrange ( s e l f . F1Left , s e l f . F1Right+1) :
m += float ( val1d ( i ) )*i
n += float ( val1d ( i ) )
b = m/n
returnb
#thenexecute
Barycentre ()
i fname==" main" :
try:
Barycentre ()
except:
fromNNBlibimportalert , formatExceptionInfo
try:
alert ( formatExceptionInfo () )
except:
raise" shouldneverhappen"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python script for NMR

2016-03-27 Thread mohamadmaaz5
On Sunday, March 27, 2016 at 6:07:43 PM UTC+2, Wildman wrote:
> On Sun, 27 Mar 2016 08:13:49 -0700, mohamadmaaz5 wrote:
> 
> >> > Hello there,
> >> > I found a python script
> 
> The formatting of the script is all wrong.  There are many
> spaces that should not be there and no indentations.  It
> could take a long time to figure it out.  It could be just
> a copy/paste problem on the part of the website.  Do you
> have the link to the original article?
> 
> -- 
>  GNU/Linux user #557453
> The cow died so I don't need your bull!

yeah this is exactly the problem, and i eliminated the spaces but still failed. 
this is the article (script in supporting info):
http://www.sciencedirect.com/science/article/pii/S1090780711002072

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python script for NMR

2016-03-27 Thread mohamadmaaz5
On Sunday, March 27, 2016 at 6:27:59 PM UTC+2, Wildman wrote:
> On Sun, 27 Mar 2016 09:15:39 -0700, mohamadmaaz5 wrote:
> 
> > On Sunday, March 27, 2016 at 6:07:43 PM UTC+2, Wildman wrote:
> >> On Sun, 27 Mar 2016 08:13:49 -0700, mohamadmaaz5 wrote:
> >> 
> >> >> > Hello there,
> >> >> > I found a python script
> >> 
> >> The formatting of the script is all wrong.  There are many
> >> spaces that should not be there and no indentations.  It
> >> could take a long time to figure it out.  It could be just
> >> a copy/paste problem on the part of the website.  Do you
> >> have the link to the original article?
> >> 
> >> -- 
> >>  GNU/Linux user #557453
> >> The cow died so I don't need your bull!
> > 
> > yeah this is exactly the problem, and i eliminated the spaces but still 
> > failed. this is the article (script in supporting info):
> > http://www.sciencedirect.com/science/article/pii/S1090780711002072
> 
> I am not finding a link to the script.  The website says that I
> have "Guest" access.  Does this mean I have to pay to see the
> script?
> 
> -- 
>  GNU/Linux user #557453
> The cow died so I don't need your bull!

can you please give me your email to send you the article ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python script for NMR

2016-03-27 Thread mohamadmaaz5
On Sunday, March 27, 2016 at 7:40:06 PM UTC+2, Peter Otten wrote:
> mohamadma...@gmail.com wrote:
> 
> > On Sunday, March 27, 2016 at 4:50:01 PM UTC+2, Joel Goldstick wrote:
> >> On Sun, Mar 27, 2016 at 10:38 AM,  wrote:
> >> 
> >> > Hello there,
> >> > I found a python script in a scientific article that enables a simple
> >> > calculation on an NMR spectrum.
> >> > I have no experience in programming and i would appreciate it if i can
> >> > communicate with someone who can write this script and send it to me by
> >> > mail in py format. It's a short script but i keep making alot of
> >> > mistaken and it fails every time.
> >> > Anyone's interested in helping me ?
> >> > Thanks
> >> > --
> >> > https://mail.python.org/mailman/listinfo/python-list
> >> >
> >> 
> >> copy the code here.  You will get help, but people don't generally write
> >> programs for others here
> >> 
> >> --
> >> Joel Goldstick
> >> http://joelgoldstick.com/ 
> >> http://cc-baseballstats.info/
> > 
> > this is the script. the thing is that i have zero experience in writing
> > and i cant find the error. all i need is to embed this script to perfome a
> > relatively simple calculation on a spectra. hope anyone can help. thanks
> > 
> > #! /usr /bin/envpython
> > #encoding:utf- 8
> > i m p o r tnmrtec . nmrNotebook . c o n t r o l l e r . C o n t r o l l e
> > r as Cont i m p o r tnmrtec . u t i l as u t i l
> > i m p o r tnmrtec . nmrNotebook . model . common .nmrCommon as nmrcom
> > c l a s sBarycentre :
> 
> If you want to turn Annex B of www.theses.fr/2014STRAJ015.pdf into runnable 
> Python please note
> 
> """
> Created by Marie-Aude Coutouly , Justine Vieville, Matthieu ...
> ...Tanty and Marc-Andre Delsuc on 2010-11-04
> Copyright ( c ) 2010 NMRTEC and IGBMC. All rights Reserved .
> 
> 
> If you didn't already contact the author(s) you should try that first -- 
> perhaps they can provide a copy of the original script.

already sent a request and waiting, thank you
-- 
https://mail.python.org/mailman/listinfo/python-list