.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/Utilites/construct_geometrical_model.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_Utilites_construct_geometrical_model.py: Construct a geometrical model ----------------------------- This example shows how to construct a geometrical model using either user defined parameters or the results from a fitting file. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Import Required Modules .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: Python import astropy.units as u from astropy.coordinates import SkyCoord from sunpy.coordinates import frames from PyThea.data.sample_data import json_fitting_file_sample_data from PyThea.geometrical_models import ellipsoid from PyThea.utils import model_fittings .. GENERATED FROM PYTHON SOURCE LINES 19-23 User defined ellipsoid ^^^^^^^^^^^^^^^^^^^^^^ You can create the a geometrical model manualy by providing an observation time, the ellipsoid center coordinates, and the geomertical parameters and use the ``ellipsoid`` class from PyThea's geometrical_models. .. GENERATED FROM PYTHON SOURCE LINES 23-31 .. code-block:: Python obstime = '2021-10-28' center = SkyCoord(90*u.degree, 0*u.degree, 1*u.R_sun, obstime=obstime, observer='earth', frame=frames.HeliographicStonyhurst) model_shock = ellipsoid(center, 1*u.R_sun, 1*u.R_sun, 1*u.R_sun, 0 * u.degree) .. GENERATED FROM PYTHON SOURCE LINES 32-36 Ellipsoid from fitting file ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Instead of manualy constructing the geometrical model you can also load the model parameters from a fitting file and then construct the model using the ``ellipsoid`` class like previously shown. .. GENERATED FROM PYTHON SOURCE LINES 38-39 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. .. GENERATED FROM PYTHON SOURCE LINES 39-42 .. code-block:: Python json_fitting_file = json_fitting_file_sample_data.fetch('FLX1p0D20211028T153500MEllipsoid.json') .. GENERATED FROM PYTHON SOURCE LINES 43-44 Then use the ``model_fittings.load_from_json(json_fitting_file)`` to load the model parameters. .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: Python model_fittings_class = model_fittings.load_from_json(json_fitting_file) .. GENERATED FROM PYTHON SOURCE LINES 48-49 Select one of the fittings and create the ellipsoid using the observation time, the ellipsoid center coordinates, and the geomertical parameters from the fitting. .. GENERATED FROM PYTHON SOURCE LINES 49-65 .. code-block:: Python model_parameters = model_fittings_class.parameters.iloc[0] obstime = model_parameters.name center = SkyCoord(model_parameters['hgln']*u.degree, model_parameters['hglt']*u.degree, model_parameters['rcenter']*u.R_sun, obstime=obstime, observer='earth', frame=frames.HeliographicStonyhurst) model_shock = ellipsoid(center, model_parameters['radaxis']*u.R_sun, model_parameters['orthoaxis1']*u.R_sun, model_parameters['orthoaxis2']*u.R_sun, model_parameters['tilt']*u.degree) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.014 seconds) .. _sphx_glr_download__examples_Utilites_construct_geometrical_model.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: construct_geometrical_model.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: construct_geometrical_model.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: construct_geometrical_model.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_