Changeset 354 for nappy/trunk/naFile1020.py
- Timestamp:
- 26/11/04 10:50:57 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nappy/trunk/naFile1020.py
r349 r354 11 11 """ 12 12 13 # 08/05/04 updated by selatham for bug fixes and new write methods 13 # 08/05/04 updated by selatham for bug fixes 14 # 18/11/04 updated by selatham for new write method & bug fixes 14 15 15 16 # Imports from python standard library … … 44 45 """ 45 46 Reads second line/section (if used) of current block of data. 46 """ 47 """ 47 48 # Now get the dependent variables 48 49 (v, rtlines)=readItemsFromUnknownLines(datalines, self.NV*self.NVPM, float) 49 50 count=0 51 print ("data read = %s") %v 50 52 for n in range(self.NV): 51 self.V[n].append([])53 #self.V[n].append([]) 52 54 for i in range(self.NVPM): # Number of steps where independent variable is implied 53 self.V[n][ivar_count].append(v[count]) 54 count=count+1 55 return rtlines 55 #self.V[n][ivar_count].append(v[count]) #18/11/04 selatham removed 56 self.V[n].append(v[count]) #18/11/04 selatham added 57 count=count+1 #18/11/04 selatham 58 print ("Variable no %s = %s") %(n,self.V[n]) 59 return rtlines 56 60 57 61 def _normalizeIndVars(self): … … 67 71 self._normalizedX="yes" 68 72 69 def writeData(self): #08/11/04 selatham 70 """ #08/11/04 selatham 71 Writes the data section of the file. #08/11/04 selatham 72 This method can be called directly by the user. #08/11/04 selatham 73 """ #08/11/04 selatham 74 for m in range(len(self.X)): #08/11/04 selatham 75 # Write Independent variable mark and auxiliary variables #08/11/04 selatham 76 var_string="%s " % self.X[m] #08/11/04 selatham 77 for a in range(self.NAUXV): #08/11/04 selatham 78 var_string=var_string+("%s " % self.A[a][m]) #08/11/04 selatham 79 self.file.write("%s\n" % var_string.rstrip()) #08/11/04 selatham 80 # Write dependant variablesf. #08/11/04 selatham 81 var_string="" #08/11/04 selatham 82 for n in range(self.NV): #08/11/04 selatham 83 var_string=var_string+("%s " %self.V[n][m]) #08/11/04 selatham 84 self.file.write("%s \n" %var_string) #08/11/04 selatham 73 def writeHeader(self): #18/11/04 selatham 74 """ #18/11/04 selatham 75 Writes FFI-specifc header section. #18/11/04 selatham 76 """ #18/11/04 selatham 77 self._writeCommonHeader() #18/11/04 selatham 78 self.file.write(("%s "*self.NIV+"\n") % tuple(self.DX)) #18/11/04 selatham 79 self.file.write(("%s\n") %self.NVPM) #18/11/04 selatham 80 self.file.write("%s\n"*self.NIV % tuple(self.XNAME)) #18/11/04 selatham 81 self._writeVariablesHeaderSection() #18/11/04 selatham 82 self._writeAuxVariablesHeaderSection() #18/11/04 selatham 83 self._writeComments() #18/11/04 selatham 85 84 85 def writeData(self): #18/11/04 selatham 86 """ #18/11/04 selatham 87 Writes the data section of the file. #18/11/04 selatham 88 This method can be called directly by the user. #18/11/04 selatham 89 """ #18/11/04 selatham 90 for m in range(len(self.X)): #18/11/04 selatham 91 # Write Independent variable mark and auxiliary variables #18/11/04 selatham 92 var_string="%s " % self.X[m] #18/11/04 selatham 93 for a in range(self.NAUXV): #18/11/04 selatham 94 var_string=var_string+("%s " % self.A[a][m]) #18/11/04 selatham 95 self.file.write("%s\n" % var_string.rstrip()) #18/11/04 selatham 96 # Write dependant variables. #18/11/04 selatham 97 var_string="" #18/11/04 selatham 98 count=0 #18/11/04 selatham 99 for n in range(self.NV): #18/11/04 selatham 100 var_string="" #18/11/04 selatham 101 for p in range(self.NVPM): #18/11/04 selatham 102 var_ind=(m*self.NVPM)+p #18/11/04 selatham 103 var_string=var_string+("%s " %self.V[n][var_ind]) #18/11/04 selatham 104 count=count+1 #18/11/04 selatham 105 self.file.write("%s \n" %var_string) #18/11/04 selatham 106
Note: See TracChangeset
for help on using the changeset viewer.