.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/plot_quickstart_tutorial.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_auto_tutorials_plot_quickstart_tutorial.py: Quickstart ========== This tutorial shows how to calculate light rays between curves calculated from scratch, meaning neither curve data nor configuration files need to be defined prior to starting the tutorial. .. GENERATED FROM PYTHON SOURCE LINES 9-17 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from greopy.initial_conditions import initial_conditions_calc from greopy.orbit_calc import geodesic_calc from greopy.emitter_observer_problem import eop_solver from greopy.emitter_observer_solution_plot import eop_plot .. GENERATED FROM PYTHON SOURCE LINES 18-20 Initial conditions and the spacetime metric are supplied as a dictionary of the following form: .. GENERATED FROM PYTHON SOURCE LINES 20-56 .. code-block:: Python config = { 'Curve_1': { 'proper_times': {'time_initial': 0, 'time_final': 7000.0}, 'initial_event': { 'x0': 0, 'radius': 6971000.0, 'theta': np.pi / 2, 'phi': 0 }, 'initial_velocity': { 'velocity_radial': 0, 'velocity_polar': 0, 'velocity_azimuthal': 0.00110815, }, }, 'Curve_2': { 'proper_times': {'time_initial': 0, 'time_final': 7000.0}, 'initial_event': { 'x0': 0, 'radius': 7071000.0, 'theta': np.pi / 2, 'phi': 0 }, 'initial_velocity': { 'velocity_radial': 0, 'velocity_polar': 0, 'velocity_azimuthal': 0.00110815, } }, 'Metric': { 'name': 'Schwarzschild', 'params': {'multipole_moments': [398600441500000.0]}, }, } .. GENERATED FROM PYTHON SOURCE LINES 57-60 The ``initial_conditions_calc`` function is used to calculate the four-velocities at the initial events from the given config dictionary and returns the events with their corresponding four-velocity: .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python event_1, velocity_1, event_2, velocity_2 = initial_conditions_calc(config) .. GENERATED FROM PYTHON SOURCE LINES 64-67 Each event with their initial four-velocity forms an initial value problem that is solved with the ``geodesic_calc`` function; the returned curves are the emitter and receiver that will be exchanging light signals: .. GENERATED FROM PYTHON SOURCE LINES 67-73 .. code-block:: Python emission_curve_data, receiver_curve_data = geodesic_calc( config, (event_1, velocity_1, event_2, velocity_2), ) .. GENERATED FROM PYTHON SOURCE LINES 74-76 Reduce the number of rows in the DataFrame to reduce number of light rays to be calculated: .. GENERATED FROM PYTHON SOURCE LINES 76-79 .. code-block:: Python emission_curve_reduced = emission_curve_data[0:600:150] .. GENERATED FROM PYTHON SOURCE LINES 80-82 The light signals can now be calculated via the ``eop_solver`` function, given the ``config`` and the two previously calculated curves: .. GENERATED FROM PYTHON SOURCE LINES 82-89 .. code-block:: Python light_rays = eop_solver(config, emission_curve_reduced, receiver_curve_data, hypersurface_approximation=True, euclidean_approximation=True) .. rst-class:: sphx-glr-script-out .. code-block:: none The seed for this computation is 44351 .. GENERATED FROM PYTHON SOURCE LINES 90-91 Optionally, the results can be visualised via the ``eop_plot`` function: .. GENERATED FROM PYTHON SOURCE LINES 91-94 .. code-block:: Python eop_plot(emission_curve_data, receiver_curve_data, light_rays) .. image-sg:: /auto_tutorials/images/sphx_glr_plot_quickstart_tutorial_001.png :alt: plot quickstart tutorial :srcset: /auto_tutorials/images/sphx_glr_plot_quickstart_tutorial_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 95-101 This plots the emission, receiver and light ray curves. From here, the plot can either be shown or saved via the corresponding matplotlib functions. For this example, the result will just be shown without saving it, which requires a Matplotlib backend, see https://matplotlib.org/stable/users/explain/figure/backends.html for more information: .. GENERATED FROM PYTHON SOURCE LINES 101-103 .. code-block:: Python plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (9 minutes 7.259 seconds) .. _sphx_glr_download_auto_tutorials_plot_quickstart_tutorial.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_quickstart_tutorial.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_quickstart_tutorial.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_quickstart_tutorial.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_