Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
phildue committed Jun 17, 2018
2 parents 9a16c07 + 7d253a3 commit a7a00d0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ ENV/

# mypy
.mypy_cache/
*.rar
61 changes: 37 additions & 24 deletions plots/plot_error_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,64 @@ def read_numeric(dataFilePath):
else:
data = np.append(data, row, axis=0)
except ValueError:
print("Not a float")
print('skip line' + row[1])
return data

## set properties
radius = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
radius = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]
network = 'm2m_lstm'
feature = ['air_temperature', 'humidity']
# feature = ['air_temperature', 'humidity']
# feature = ['air_temperature']
feature = ['air_temperature', 'wind_north', 'wind_east']
features = [['air_temperature'], ['air_temperature', 'wind_north', 'wind_east']]

# set path
path = os.path.join('..', 'out')
dataFileID = 'log.csv'
dataStatFileId = 'data_stat.csv'

# init some stuff for looping
RMS = [0] * len(radius)
RMS_norm = [0] * len(radius)
rCounter = 0
RMS = [[0] * len(radius), [0] * len(radius)]
RMS_norm = [[0] * len(radius), [0] * len(radius)]

# loop over radii
for r in radius:

# init path
fullPath = os.path.join(path, network + '_'.join(feature), str(r))
dataFilePath = os.path.join(fullPath, dataFileID)
dataStatPath = os.path.join(fullPath, dataStatFileId)

data = read_numeric(dataFilePath)
dataStat = read_numeric(dataStatPath)

RMS_norm[rCounter] = data[-1, -1]
RMS[rCounter] = dataStat[0][1] * dataStat[0][1] * data[-1, -1]

rCounter = rCounter + 1
featCounter = 0

for feature in features:

rCounter = 0
# loop over radii
for r in radius:

# init path
fullPath = os.path.join(path, network + '_'.join(feature), str(r))
dataFilePath = os.path.join(fullPath, dataFileID)
dataStatPath = os.path.join(fullPath, dataStatFileId)

data = read_numeric(dataFilePath)
dataStat = read_numeric(dataStatPath)

print( data[-1, -1])

RMS_norm[featCounter][rCounter] = data[-1, -1]
RMS[featCounter][rCounter] = dataStat[0][1] * dataStat[0][1] * data[-1, -1]

rCounter = rCounter + 1

featCounter = featCounter + 1
# plot results
fig, ax = plt.subplots( nrows=1, ncols=1 )
ax.plot(radius, RMS)
plt.ylabel('Mean squared error [C^2]')
tempPlt, = ax.plot(radius, RMS[0], label='temperature')
windPlt, = ax.plot(radius, RMS[1], label='temperatur, wind speed')
plt.ylabel('Mean squared error [$^\circ$ C$^2$]')
plt.xlabel('radius [km]')
plt.grid(True)
plt.title(' '.join(feature))
plt.title('Error for Different Features and Radii')

handles, labels = ax.get_legend_handles_labels()
plt.legend(handles=[tempPlt, windPlt])

fig.savefig(os.path.join('..', 'fig', 'error_' + '_'.join(feature) + '.png'))
fig.savefig(os.path.join('..', 'fig', 'error_' + '_'.join(feature) + '.eps'))

plt.show(fig)
# plt.close(fig)

0 comments on commit a7a00d0

Please sign in to comment.