From b3888f315b5aa1debf01401d2ab15a14e717cce6 Mon Sep 17 00:00:00 2001 From: Loren Matilsky Date: Wed, 3 Apr 2024 10:48:06 -0600 Subject: [PATCH] Update reference_tools.py Addresses Nick's comment about version number. --- post_processing/reference_tools.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/post_processing/reference_tools.py b/post_processing/reference_tools.py index c83fad3d..e1e90495 100644 --- a/post_processing/reference_tools.py +++ b/post_processing/reference_tools.py @@ -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] @@ -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