.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_bed_shear_stress.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_bed_shear_stress.py: Create bed shear stress example =============================== .. GENERATED FROM PYTHON SOURCE LINES 6-21 .. code-block:: default import pandas as pd import toto import matplotlib.pyplot as plt from toto.inputs.txt import TXTfile import os # read the file hindcast='https://raw.githubusercontent.com/calypso-science/Toto/master/_tests/txt_file/wave_currents.txt.csv' os.system('wget %s ' % hindcast) hd=TXTfile(['wave_currents.txt.csv'],colNamesLine=1,skiprows=1,unitNamesLine=0,time_col_name={'year':'year','month':'month','day':'day','hour':'hour','min':'Minute'}) hd.reads() hd.read_time() hd=hd._toDataFrame() .. GENERATED FROM PYTHON SOURCE LINES 22-23 Switch from U and V to spd an drr .. GENERATED FROM PYTHON SOURCE LINES 23-25 .. code-block:: default hd[0]['spd']=hd[0].DataTransformation.uv_to_spddir(u='Ve',v='Vn')['spd'] .. GENERATED FROM PYTHON SOURCE LINES 26-27 Calculate bed shear stress .. GENERATED FROM PYTHON SOURCE LINES 27-34 .. code-block:: default bed_shear=hd[0].DataTransformation.bed_shear_stress(spd='spd',hs='hs',tp='tp', args={'mode':'3D', 'water_depth':10, 'rho_water':1027, 'z0': 0.001, }) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none angle between direction of travel of wave and current not implemented yet .. GENERATED FROM PYTHON SOURCE LINES 35-59 .. code-block:: default fig=plt.figure() ax1 = plt.subplot(211) ax1.plot(hd[0].index,hd[0]['spd'],'b',label='Current speed') ax1.set_ylabel('Current speed [m/s]',color='b') ax1.tick_params(axis='y', color='b', labelcolor='b') ax1bis = ax1.twinx() ax1bis.plot(hd[0].index,hd[0]['hs'],'r',label='Wave height') ax1bis.set_ylabel('Wave height [m]',color='r') ax1bis.tick_params(axis='y', color='r', labelcolor='r') fig.autofmt_xdate() ax2 = plt.subplot(212) p1=ax2.plot(bed_shear.index,bed_shear['tau_cw'],'b',label='Mean bed shear stress during wave cycle') ax2.set_ylabel('Mean bed shear stress [N/m2]',color='b') ax2.tick_params(axis='y', color='b', labelcolor='b') ax2bis = ax2.twinx() p2=ax2bis.plot(bed_shear.index,bed_shear['tau_cw_max'],'r',label='Maximum bed shear stress during wave cycle') ax2bis.tick_params(axis='y', color='r', labelcolor='r') ax2bis.set_ylabel('Max bed shear stress [N/m2]',color='r') fig.autofmt_xdate() plt.tight_layout() plt.show() .. image:: /gallery/images/sphx_glr_plot_bed_shear_stress_001.png :alt: plot bed shear stress :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.332 seconds) .. _sphx_glr_download_gallery_plot_bed_shear_stress.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_bed_shear_stress.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_bed_shear_stress.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_