I'm really new with python. So maybe my question is really basic...For my work I'm checking different parameters in a period of time. For the Beginning with Python I wanted to plot a simple List with daily measured Temperature-values for a month. In the List I've three splits like these following structure:
Day -TAB- Temperature -TAB- Nr
My Code:
import pylab as pl
import numpy as np
filename = "u_netCDF_write"
file = open(filename)
NoOfValues = 31
counter=0
data = []
for line in file:
if counter <= NoOfValues:
data.append(line.strip('\n').strip('\t').split(' '))
if len(data[-1]) == 4:
data[-1].pop(3)
counter+=1
x = np.linspace(0,30,31)
data = np.transpose(data)
for i in range(len(data[2])):
data[2][i] = float(data[2][i])-273.15
When I try to plot a Temperature-per-Day-Plot I get the Error-Message:
Traceback (most recent call last):
File ".../.../unetCDFplot.py", line 43, in <module>
data[2][i] = float(data[2][i])-273.15
ValueError: invalid literal for float(): 03.07.2014
It looks like that the Code didn't transpose the Data. Why is that so? Can anybody help me? Thanks!