Iteration, $X, $Y
1,0.581261625,0.010561718
2,0.470764982,0.01282931
3,0.44202262,0.011346878
4,0.447475587,0.011324991
I have this file in this form, out of 500 values I put the first five. For every $X and $Y at the same iteration there is Z that will be calculated from the following code from an old X and Y.
My following code is to call the file and to find the equivalent Z for each $X and $Y that is already provided in the code.
import sys
from math import log
import datetime
import re
import numpy as np
from scipy import interpolate
from scipy.interpolate import griddata
import itertools
from scipy.optimize import curve_fit
##interpolation data for Z
xx = 0.15, 0.33, 0.35, 0.5, 0.67, 0.8
yy = 0.01, 0.05, 0.08, 0.1, 0.15, 0.2
zz = 0.75, 0.81, 0.83, 1.00, 0.92, 0.91,
# Read parameter file
parametersAndValues = {}
parameterFile = open('ParameterValues') #open(os.environ['RAVEN_PARAMETERFILE'])
try:
for line in parameterFile:
parametersAndValues[line.split()[0]] = ((float(line.split()[1])))
finally:
parameterFile.close()
X = parametersAndValues.get('$X')
Y = parametersAndValues.get('$Y')
for parameter in parametersAndValues:
( parameter + ' = ' + str(parametersAndValues.get(parameter)))
This part of the code is to interpolate the values of X and Y to find Z
##interpolation data for TLMIXPAR
tck = interpolate.bisplrep(xx, yy, zz, s=0)
def givemeomega(X,Y):
result = interpolate.bisplev(X,Y,tck)
return '{:.5f}'.format(min(1.0, result))
The error code I keep getting is ValueError: could not convert string to float: '$X,'
, so I am not able to call the value properly neither find the proper Z for $X and $Y
I appreciate all the help you can offer