diff --git a/.gitignore b/.gitignore index f4e9d37..a514d6e 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,4 @@ ENV/ # mypy .mypy_cache/ +*.rar \ No newline at end of file diff --git a/plots/plot_error_radius.py b/plots/plot_error_radius.py index 3012a0e..644d226 100644 --- a/plots/plot_error_radius.py +++ b/plots/plot_error_radius.py @@ -27,15 +27,15 @@ 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') @@ -43,35 +43,48 @@ def read_numeric(dataFilePath): 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) \ No newline at end of file