Skip to content

Commit

Permalink
Update reference_tools.py
Browse files Browse the repository at this point in the history
Addresses Nick's comment about version number.
  • Loading branch information
illorenzo7 authored Apr 3, 2024
1 parent d9554ea commit b3888f3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions post_processing/reference_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def write(self, filename='ecoefs.dat'):
fd.close()

def read(self, filename='equation_coefficients'):

class_version = self.version
fd = open(filename,'rb')
picheck = numpy.fromfile(fd,dtype='int32',count=1)[0]

Expand All @@ -93,13 +93,21 @@ def read(self, filename='equation_coefficients'):
self.nconst = 10
self.cset = numpy.fromfile(fd,dtype='int32',count=self.nconst)
self.fset = numpy.fromfile(fd,dtype='int32',count=self.nfunc)
self.constants = numpy.fromfile(fd,dtype='float64',count=self.nconst)
self.constants = numpy.fromfile(fd,dtype='float64',count=self.nconst)
self.nr = numpy.fromfile(fd,dtype='int32',count=1)[0]
self.radius = numpy.fromfile(fd,dtype='float64',count=self.nr)
functions=numpy.fromfile(fd,dtype='float64',count=self.nr*self.nfunc)
self.functions = numpy.reshape(functions, (self.nfunc,self.nr))
fd.close()

# now if we read in v. 1, convert current instance to v. 2
if self.version == 1:
self.nconst = 11
self.version = class_version
self.constants[10] = 1.
print("Version of input file was 1.")
print("Converting current equation_coefficients instance's version to %i." %class_version)

class background_state:
nr = None
radius = None
Expand Down

0 comments on commit b3888f3

Please sign in to comment.