.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/Basic_Plots/plot_kinematics.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__examples_Basic_Plots_plot_kinematics.py: Plot model kinematics --------------------- In this example, we use PyThea's utilities to plot the kinematics of the geometrical model from a fitting file. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Import Required Modules .. GENERATED FROM PYTHON SOURCE LINES 10-19 .. code-block:: Python from datetime import datetime import matplotlib.dates as mdates import matplotlib.pyplot as plt from IPython.display import display from PyThea.data.sample_data import json_fitting_file_sample_data from PyThea.utils import model_fittings, plot_fitting_model .. GENERATED FROM PYTHON SOURCE LINES 20-22 Import a sample JSON fitting file using ``json_fitting_file_sample_data.fetch()`` method. This sample data contains a series of fitted ellipsoids for a selected event. Then use the ``model_fittings.load_from_json(json_fitting_file)`` to load the model parameters. .. GENERATED FROM PYTHON SOURCE LINES 22-26 .. code-block:: Python json_fitting_file = json_fitting_file_sample_data.fetch('FLX1p0D20211028T153500MEllipsoid.json') model_fittings_class = model_fittings.load_from_json(json_fitting_file) .. GENERATED FROM PYTHON SOURCE LINES 27-28 Print the information about the selected event and geometrical model using ``print()`` statements and the parameters of the model fittings using ``display(model_fittings_class.parameters)`` .. GENERATED FROM PYTHON SOURCE LINES 28-34 .. code-block:: Python print(f'Selected Event: {model_fittings_class.event_selected}') print(f'Geometrical Model: {model_fittings_class.geometrical_model}') display(model_fittings_class.parameters) .. rst-class:: sphx-glr-script-out .. code-block:: none Selected Event: FLX1.0|2021-10-28T15:35:00 Geometrical Model: Ellipsoid hgln hglt crln ... alpha imager fits_file 2021-10-28 15:48:18.842 3.62 -25.07 274.118677 ... 0.86 LC2 2021-10-28 16:00:17.986 3.62 -23.56 274.008914 ... 0.78 LC2 2021-10-28 16:06:14.730 3.62 -22.35 273.954464 ... 0.78 LC3 2021-10-28 16:12:18.325 3.62 -21.25 273.898969 ... 0.77 LC2 2021-10-28 16:18:14.323 3.62 -21.00 273.844633 ... 0.77 LC3 2021-10-28 16:30:14.364 3.62 -20.34 273.734733 ... 0.77 LC3 [6 rows x 15 columns] .. GENERATED FROM PYTHON SOURCE LINES 35-40 Use the stored curve fitting parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This part uses the curve fitting method parameters that are stored in the json fitting file. The curve fitting parameters are selected by the user during the fitting process in the application. View the curve fitting method parameters. These consist of the method (``type``) of the curve fitting ('polynomial' in this example) and the ``order`` (2nd order in this example). .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python print(f'Fitting Parameters: {model_fittings_class.kinematics["fit_method"]}') .. rst-class:: sphx-glr-script-out .. code-block:: none Fitting Parameters: {'type': 'polynomial', 'order': 2} .. GENERATED FROM PYTHON SOURCE LINES 44-45 Use the utility function ``plot_fitting_model`` to plot the kinematic figures. Select for ``plt_type`` the ``HeightT`` option to plot the height-time profile of the geometrical fitting and the ``SpeedT`` to plot the speed-time profile. .. GENERATED FROM PYTHON SOURCE LINES 45-61 .. code-block:: Python fig, axis = plot_fitting_model(model_fittings_class, fit_args=model_fittings_class.kinematics['fit_method'], plt_type='HeightT') axis.set_xlim([datetime(2021, 10, 28, 15, 40, 0), datetime(2021, 10, 28, 16, 40, 0)]) axis.xaxis.set_minor_locator(mdates.MinuteLocator(byminute=range(60), interval=1)) plt.show() fig, axis = plot_fitting_model(model_fittings_class, fit_args=model_fittings_class.kinematics['fit_method'], plt_type='SpeedT') axis.set_xlim([datetime(2021, 10, 28, 15, 40, 0), datetime(2021, 10, 28, 16, 40, 0)]) axis.xaxis.set_minor_locator(mdates.MinuteLocator(byminute=range(60), interval=1)) axis.set_ylim([1000, 2200]) plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_001.png :alt: Event: FLX1.0|2021-10-28T15:35:00 | polynomial2 :srcset: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_001.png :class: sphx-glr-multi-img * .. image-sg:: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_002.png :alt: Event: FLX1.0|2021-10-28T15:35:00 | polynomial2 :srcset: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_002.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 62-66 Manual fitting parameters ^^^^^^^^^^^^^^^^^^^^^^^^^ To use other curve fitting parameters parse different 'type' and 'order'. In the example bellow we plot the height time profile using a linear fit. .. GENERATED FROM PYTHON SOURCE LINES 66-75 .. code-block:: Python fit_method = {'type': 'polynomial', 'order': 1} fig, axis = plot_fitting_model(model_fittings_class, fit_args=fit_method, plt_type='HeightT') axis.set_xlim([datetime(2021, 10, 28, 15, 40, 0), datetime(2021, 10, 28, 16, 40, 0)]) axis.xaxis.set_minor_locator(mdates.MinuteLocator(byminute=range(60), interval=1)) plt.show() .. image-sg:: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_003.png :alt: Event: FLX1.0|2021-10-28T15:35:00 | polynomial1 :srcset: /_examples/Basic_Plots/images/sphx_glr_plot_kinematics_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.576 seconds) .. _sphx_glr_download__examples_Basic_Plots_plot_kinematics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_kinematics.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_kinematics.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_kinematics.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_