Can it possible to make this script short, so that multiple data and multiple output file can be managed efficiently?
def create_output_file(self, **kwargs):
print 'Now output file created'
filename1 = 'res_norm.txt'
filename2 = 'bound.txt'
filename3 = 'soln_2norm.txt'
matrixRes = np.vstack((self.iter_list, self.res_norm)).T
matrixBound = np.vstack((self.iter_list, self.bound)).T
matrixSol2 = np.vstack((self.iter_list, self.soln_2nrm)).T
fo1 = open(filename1, "a+")
fo2 = open(filename2, "a+")
fo3 = open(filename3, "a+")
fo1.write('# Residual Norm %s' % (kwargs['s']))
fo2.write('# Bound %s' % (kwargs['s']))
fo3.write('# Solution_2Norm %s' % (kwargs['s']))
fo1.write('\n')
fo2.write('\n')
fo3.write('\n')
np.savetxt(fo1, matrixRes, fmt='%f \t %1.4e')
np.savetxt(fo2, matrixBound, fmt='%f \t %1.4e')
np.savetxt(fo3, matrixSol2, fmt='%f \t %1.4e')
fo1.write('\n')
fo1.write('\n')
fo2.write('\n')
fo2.write('\n')
fo3.write('\n')
fo3.write('\n')
fo1.close()
fo2.close()
fo3.close()
return