Difference between revisions of "EGR 103/Fall 2019/Minilab 3"
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
# %% Load data | # %% Load data | ||
− | edata = pandas.read_excel( | + | edata = pandas.read_excel("file.xlsx") |
− | col_1_stuff = edata.values[:,0].copy() | + | col_1_stuff = edata.values[:, 0].copy() |
− | col_2_stuff = edata.values[:,1].copy() | + | col_2_stuff = edata.values[:, 1].copy() |
</syntaxhighlight> | </syntaxhighlight> | ||
:* [[Python:Plotting]] | :* [[Python:Plotting]] | ||
:* [[Python:Interpolation]] | :* [[Python:Interpolation]] | ||
:* [[Python:Extrema]] | :* [[Python:Extrema]] | ||
− | :* [https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.interpolate.CubicSpline.html scipy.interpolate.CubicSpline¶] at [docs.scipy.org docsscipy.org] | + | :* [https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.interpolate.CubicSpline.html scipy.interpolate.CubicSpline¶] at [http://docs.scipy.org docsscipy.org] |
* Problem 2.5.2 | * Problem 2.5.2 | ||
− | ** | + | ** [https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.simps.html scipy.integrate.simps] at [http://docs.scipy.org docsscipy.org] |
** Note that the denominator in the line of action calculation is $$f_t$$, which you already calculated. | ** Note that the denominator in the line of action calculation is $$f_t$$, which you already calculated. | ||
− | ** If you want to see a graph of the cross section (i.e. Figure 19.9(b)), assuming you call the height above the bottom $z$ and the width at that height $wz$, you can add the following code: | + | ** If you want to see a graph of the cross section (i.e. Figure 19.9(b)), assuming you call the height above the bottom $$z$$ and the width at that height $$wz$$, you can add the following code: |
− | <syntaxhighlight lang=python> | + | ::<syntaxhighlight lang=python> |
fig = plt.figure(num=1, clear=True) | fig = plt.figure(num=1, clear=True) | ||
− | ax = fig.add_subplot(1,1,1) | + | ax = fig.add_subplot(1, 1, 1) |
zval = np.block([z[::-1], z[:]]) | zval = np.block([z[::-1], z[:]]) | ||
− | wval = np.block([-wz[::-1]/2,wz[:]/2]) | + | wval = np.block([-wz[::-1] / 2, wz[:] / 2]) |
− | ax.plot(wval, zval, | + | ax.plot(wval, zval, "k-") |
− | ax.axis( | + | ax.axis("equal") |
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:53, 3 December 2019
- Problem 2.5.1
- To load data froman Excel file with headers:
import pandas # %% Load data edata = pandas.read_excel("file.xlsx") col_1_stuff = edata.values[:, 0].copy() col_2_stuff = edata.values[:, 1].copy()
- Problem 2.5.2
- scipy.integrate.simps at docsscipy.org
- Note that the denominator in the line of action calculation is $$f_t$$, which you already calculated.
- If you want to see a graph of the cross section (i.e. Figure 19.9(b)), assuming you call the height above the bottom $$z$$ and the width at that height $$wz$$, you can add the following code:
fig = plt.figure(num=1, clear=True) ax = fig.add_subplot(1, 1, 1) zval = np.block([z[::-1], z[:]]) wval = np.block([-wz[::-1] / 2, wz[:] / 2]) ax.plot(wval, zval, "k-") ax.axis("equal")