-- program to extract the values of gradient strength from a Varian DOSY experiment -- run this script ONCE to let iNMR process the current spectrum as a DOSY -- no need to run it again in future, because the results are saved into a file called "zeta" function ValueNamed( name ) local len = string.len( name ) + 1 name = name.." " local line repeat line = string.sub( io.read("*line"), 1, len ) until line == name _ = io.read("*number") -- skip the first number return io.read("*number") end function ArrayNamed( name ) local len = string.len( name ) local line T = {} repeat line = string.sub( io.read("*line"), 1, len ) until line == name local n = io.read("*number") -- the first number is the length of the array for i=1,n do T[i] = io.read("*number") end return n, T end -- the main program starts here print "\n\n=============================" local path = pathtofile() last = 1 while true do slash = string.find( path, "/", last + 1 ) if not slash then break end last = slash end path = string.sub( path, 1, last ) -- path to the folder io.input( path.."procpar" ) -- the following parameters must be found exactly in this order... DAC_to_G = 0.01 * ValueNamed( "DAC_to_G" ) -- calibration DELTA = ValueNamed( "del" ) dosytimecubed = ValueNamed( "dosytimecubed" ) dosygamma = ValueNamed( "dosygamma" ) -- gyromagnetic ratio delta = ValueNamed( "gt1" ) n, gzlvl1 = ArrayNamed( "gzlvl1" ) -- gradient strength -- ... otherwise they are not found: in this case, rewrite the script D_d = DELTA - delta / 3 --Dconst = dosygamma * dosygamma * delta * delta * D_d -- UNCOMMENT IF DOSYTIMECUBED IS NOT FOUND Dconst = dosytimecubed * dosygamma * dosygamma -- COMMENT IF DOSYTIMECUBED IS NOT FOUND print( "DELTA = ", DELTA ) print( "delta = ", delta ) print( "dosygamma = ", dosygamma ) print( "DOSYconstant = ", Dconst ) io.output( path.."zeta" ) for i = 1,n do local G = DAC_to_G * gzlvl1[i] -- print( G ) io.write( G * G * Dconst, "\n" ) -- values required by iNMR (independent variable) end io.close( ) -- closing and saving the output file zeta print (n, "values extracted and converted")