From 7e02c64dffde49ab4ce74f2400f76a39e5fa0c11 Mon Sep 17 00:00:00 2001 From: IvBu <st116086@stud.uni-stuttgart.de> Date: Mon, 18 Sep 2023 11:13:08 +0200 Subject: [PATCH] [groundwater] stop using pandas --- lecture/mhs/groundwater/contourplots.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lecture/mhs/groundwater/contourplots.py b/lecture/mhs/groundwater/contourplots.py index b0d227dd..8f9063f5 100644 --- a/lecture/mhs/groundwater/contourplots.py +++ b/lecture/mhs/groundwater/contourplots.py @@ -1,8 +1,7 @@ import matplotlib.pyplot as plt import numpy as np -import pandas as pd -#Instructions: First execute the `groundwater` test, a file called "contourfile.txt" will be written to the respective build-cmake folder. Within the build-cmake/.../groundwater folder you can then run the python script via e.g. `python3 contourPlots.py` to plot the contour and streamlines of the given problem. +#Instructions: First execute the `groundwater` test, a file called "contourfile.txt" will be written to the respective build-cmake folder. Within the build-cmake/.../groundwater folder you can then run the python script via e.g. `python3 contourplots.py` to plot the contour and streamlines of the given problem. plt.rcParams.update({'font.size': 10}) @@ -27,12 +26,12 @@ cells = parameters.get("Cells").split() nx = int(cells[0]) ny = int(cells[1]) #read in the data which should be plotted -myData = pd.read_csv('contourfile.txt') #choose the correct name of the data file +dataField = np.genfromtxt('contourfile.txt', delimiter=',', dtype=None, names=True, encoding='utf-8') #-------PREPARING DATA FOR CONTOUR PLOT------- -xArray = myData['x'].values #read in a pandas data column and immediately convert it to a numpy array -yArray = myData['y'].values -hArray = myData['h'].values +xArray = dataField['x'] +yArray = dataField['y'] +hArray = dataField['h'] #reshape input from a vector to a matrix x = xArray.reshape(ny,nx) xLinspace = x[0] # each row is the same, take the first @@ -57,8 +56,8 @@ fig.savefig('isolineplot.png', dpi=300) #-------PREPARING DATA FOR STREAMLINE PLOT------- #read in the data for the streamlines -vxArray = myData['v_x'].values #read in a pandas data column and immediately convert it to a numpy array -vyArray = myData['v_y'].values +vxArray = dataField['v_x'] +vyArray = dataField['v_y'] #reshape velocity fields from a vector to a matrix vx = vxArray.reshape(ny,nx) vy = vyArray.reshape(ny,nx) -- GitLab