.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_source_auto_examples_correct_ship_wind_data.py>`     to download the full example code
    .. rst-class:: sphx-glr-example-title

    .. _sphx_glr_source_auto_examples_correct_ship_wind_data.py:


Example on how to correct wind data for ship motion
---------------------------------------------------

This example shows how to calculate course and speed
over ground of the ship and use it to correct the
wind speed and direction data.


.. code-block:: default

    import act
    import xarray as xr

    # Read in the navigation data, mainly for the lat/lon
    nav = act.io.armfiles.read_netcdf(
        act.tests.sample_files.EXAMPLE_NAV)

    # Calculate course and speed over ground from the NAV
    # lat and lon data
    nav = act.utils.ship_utils.calc_cog_sog(nav)

    # Read in the data containing the wind speed and direction
    aosmet = act.io.armfiles.read_netcdf(
        act.tests.sample_files.EXAMPLE_AOSMET)

    # Merge the navigation and wind data together
    # This have been previously resampled to 1-minute data
    obj = xr.merge([nav, aosmet], compat='override')

    # Call the correction for the winds.  Note, that this only
    # corrects for ship course and speed, not roll and pitch.
    obj = act.corrections.ship.correct_wind(obj)

    nav.close()
    aosmet.close()
    obj.close()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.000 seconds)


.. _sphx_glr_download_source_auto_examples_correct_ship_wind_data.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: correct_ship_wind_data.py <correct_ship_wind_data.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: correct_ship_wind_data.ipynb <correct_ship_wind_data.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
