.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_plot_spectra.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_plot_spectra.py: Plotting wave spectra data ================================================ .. GENERATED FROM PYTHON SOURCE LINES 7-18 .. code-block:: Python from pathlib import Path from trajan.readers.omb import read_omb_csv from trajan.plot.spectra import plot_trajan_spectra import coloredlogs import datetime # adjust the level of information printed # coloredlogs.install(level='error') coloredlogs.install(level='debug') .. GENERATED FROM PYTHON SOURCE LINES 19-24 .. code-block:: Python # load the data from an example file with several buoys and a bit of wave spectra data path_to_test_data = Path.cwd().parent / "tests" / "test_data" / "csv" / "omb3.csv" xr_data = read_omb_csv(path_to_test_data) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG read path to pandas 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG omb_dataframe at index 94 is: Date Time (UTC) 16/Jun/2022 18:27:19 Device drifter_2 Direction MO Payload NaN Approx Lat/Lng 74.36745,3.3274 Payload (Text) NaN Length (Bytes) 0 Credits 1 Name: 94, dtype: object this is empty (Length (Bytes) is 0), drop 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG start applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG done applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG start applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG done applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG start applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.readers.omb[2149] DEBUG done applying sliding_filter_nsigma 2024-10-31 20:48:25 fv-az1024-670 trajan.accessor[2149] DEBUG Detecting time-dimension for "obs".. 2024-10-31 20:48:25 fv-az1024-670 trajan.accessor[2149] DEBUG Detected obs-dim: obs, detected time-dim: time. 2024-10-31 20:48:25 fv-az1024-670 trajan.accessor[2149] DEBUG Detected un-structured (2D) trajectory dataset 2024-10-31 20:48:25 fv-az1024-670 trajan.traj[2149] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2024-10-31 20:48:25 fv-az1024-670 trajan.traj[2149] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2024-10-31 20:48:25 fv-az1024-670 trajan.traj[2149] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2024-10-31 20:48:25 fv-az1024-670 trajan.traj[2149] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: Python # plot the spectra in one command plot_trajan_spectra(xr_data) .. image-sg:: /gallery/images/sphx_glr_example_plot_spectra_001.png :alt: example plot spectra :srcset: /gallery/images/sphx_glr_example_plot_spectra_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG tuple_date_start_end = None 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG date_start_md = np.float64(19158.39047453704) 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG date_end_md = np.float64(19161.514988425926) 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG tuple_vrange_pcolor = None 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG vmin_pcolor = -3.0 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG vmax_pcolor = 1.0 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG plt_show = True 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG fignamesave = None 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_1' 2024-10-31 20:48:25 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_2' 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_3' 2024-10-31 20:48:26 fv-az1024-670 matplotlib.colorbar[2149] DEBUG locator: .. GENERATED FROM PYTHON SOURCE LINES 30-37 .. code-block:: Python # plot the spectra specifying more options by hand; it is also possible to automatically # save the figure by setting fignamesave="some_name.png" time_start = datetime.datetime(2022, 6, 16, 12, 30, 0) time_end = datetime.datetime(2022, 6, 17, 8, 45, 0) plot_trajan_spectra(xr_data, (time_start, time_end), (-2.0, 1.5)) .. image-sg:: /gallery/images/sphx_glr_example_plot_spectra_002.png :alt: example plot spectra :srcset: /gallery/images/sphx_glr_example_plot_spectra_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG tuple_date_start_end = (datetime.datetime(2022, 6, 16, 12, 30), datetime.datetime(2022, 6, 17, 8, 45)) 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG date_start_md = np.float64(19159.520833333332) 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG date_end_md = np.float64(19160.364583333332) 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG tuple_vrange_pcolor = (-2.0, 1.5) 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG vmin_pcolor = -2.0 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG vmax_pcolor = 1.5 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG plt_show = True 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG fignamesave = None 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_1' 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_2' 2024-10-31 20:48:26 fv-az1024-670 trajan.plot.spectra[2149] DEBUG crrt_instrument = 'drifter_3' 2024-10-31 20:48:26 fv-az1024-670 matplotlib.colorbar[2149] DEBUG locator: .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.533 seconds) .. _sphx_glr_download_gallery_example_plot_spectra.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_plot_spectra.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_plot_spectra.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_plot_spectra.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_