Skip to content
Snippets Groups Projects
Commit 7e02c64d authored by IvBu's avatar IvBu
Browse files

[groundwater] stop using pandas

parent ed125fc4
No related branches found
No related tags found
1 merge request!207Fix/contour plots
Pipeline #35729 passed
Pipeline: dumux-lecture

#35730

    import matplotlib.pyplot as plt import matplotlib.pyplot as plt
    import numpy as np 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}) plt.rcParams.update({'font.size': 10})
    ...@@ -27,12 +26,12 @@ cells = parameters.get("Cells").split() ...@@ -27,12 +26,12 @@ cells = parameters.get("Cells").split()
    nx = int(cells[0]) nx = int(cells[0])
    ny = int(cells[1]) ny = int(cells[1])
    #read in the data which should be plotted #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------- #-------PREPARING DATA FOR CONTOUR PLOT-------
    xArray = myData['x'].values #read in a pandas data column and immediately convert it to a numpy array xArray = dataField['x']
    yArray = myData['y'].values yArray = dataField['y']
    hArray = myData['h'].values hArray = dataField['h']
    #reshape input from a vector to a matrix #reshape input from a vector to a matrix
    x = xArray.reshape(ny,nx) x = xArray.reshape(ny,nx)
    xLinspace = x[0] # each row is the same, take the first xLinspace = x[0] # each row is the same, take the first
    ...@@ -57,8 +56,8 @@ fig.savefig('isolineplot.png', dpi=300) ...@@ -57,8 +56,8 @@ fig.savefig('isolineplot.png', dpi=300)
    #-------PREPARING DATA FOR STREAMLINE PLOT------- #-------PREPARING DATA FOR STREAMLINE PLOT-------
    #read in the data for the streamlines #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 vxArray = dataField['v_x']
    vyArray = myData['v_y'].values vyArray = dataField['v_y']
    #reshape velocity fields from a vector to a matrix #reshape velocity fields from a vector to a matrix
    vx = vxArray.reshape(ny,nx) vx = vxArray.reshape(ny,nx)
    vy = vyArray.reshape(ny,nx) vy = vyArray.reshape(ny,nx)
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment