<s> import glob <EOL> import numpy as np <EOL> from nmrglue . analysis . leastsqbound import leastsqbound <EOL> def fit_func ( p , x ) : <EOL> A , R2 = p <EOL> return A * np . exp ( - <NUM_LIT:1.0> * np . array ( x ) * R2 / <NUM_LIT> ) <EOL> def residuals ( p , y , x ) : <EOL> err = y - fit_func ( p , x ) <EOL> return err <EOL> relaxation_times = np . loadtxt ( "<STR_LIT>" ) <EOL> x0 = [ <NUM_LIT:1.0> , <NUM_LIT> ] <EOL> bounds = [ ( <NUM_LIT> , <NUM_LIT> ) , ( None , None ) ] <EOL> output = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> output . write ( "<STR_LIT>" ) <EOL> for filename in glob . glob ( '<STR_LIT>' ) : <EOL> peak = filename [ : <NUM_LIT:3> ] <EOL> print "<STR_LIT>" , peak <EOL> trajectory = np . loadtxt ( filename ) <EOL> x , ier = leastsqbound ( residuals , x0 , bounds = bounds , <EOL> args = ( trajectory , relaxation_times ) ) <EOL> output . write ( '<STR_LIT>' % ( peak , x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] , ier ) ) <EOL> output . close ( ) </s>
