for c in Waters: print >> myfile, ' ' peakcount = systems[(b, c)] shift = peak[peakcount] print >> myfile2, '{0} {1} {2}'.format('#File:', b, c) for d in frange(start_time, end_time, 0.5): l = d + 0.5 l = str(l) d = str(d) xvg = XVG() filename = 'g_rad_dmap_%dpc_w%d_%sns_%sns.xvg'%(b,c,d,l, ) if not os.path.isfile(filename): print >> myfile, '{0} {1} {2}'.format(filename, 'nan', 'nan') print >> myfile2, '{0} {1}'.format('nan', 'nan') continue xvg.read(filename) input = xvg.array x = input[0] # Here we create the array "zcoord" with the z-coordinates of the slices subtracting the shift value. slicestotal = len(input) - 1 S = ZLENGTH/ slicestotal zcoord = np.zeros(len(input)-1) for i in range(1,len(input)): zcoord[i-1] = (S *(i-1))-shift # We set the number of the first slice as "zeroslice", which will be used later for leaving the first 8nm above the surface out of the fitted data. zeroslice = 0 cnt = 0 for slicepos in zcoord: if slicepos >= 0.0: zeroslice = cnt