Closed smubeeeen closed 2 years ago
Not sure if you have already solved the problem. A simple solution would be to use python csv reader or numpy and then write it as pickle. However, in saying so, it is difficult to suggest a solution without looking at the data structure.
Secondly, even if you convert it to pickle, the pickle should provide the data in a format as expected by the functions you are calling from SkillMetrics package. I think you have looked through the test cases, which use pickle as the data used is stored in such fomat.
However, if you look further below, you can see
taylor_stats1 = sm.taylor_statistics(data.pred1,data.ref,'data')
taylor_stats2 = sm.taylor_statistics(data.pred2,data.ref,'data')
taylor_stats3 = sm.taylor_statistics(data.pred3,data.ref,'data')
where, it just expects 1D numpy array. I would suggest you to use numpy arrays. A simple example would be something like this
data = np.loadtxt("file.csv", delimiter=',')
taylor_stats1 = sm.taylor_statistics(data[:,1],data[:, 0],'data')
Here, I have assumed that your csv file has two columns, where first column is observed data and second column is model data. Also, I have assumed at it is comma separated.
You don't need to convert your csv file to pkl. I would directly read the csv file into Python using pandas or some other package. I'm sure you can find many examples on the Internet on how to do this. Then just store your data columns into lists and pass these to the taylor_statistics function. Using the loadtxt
example above this would be
taylor_stats1 = sm.taylor_statistics(data[:,1],data[:, 0])
sir, i have a csv file of my model datasets i need to make the tailor diagram but your example code only read a pkl file is there any way i can change my csv to pkl