.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/visualising_instruments.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_examples_visualising_instruments.py: Visualising Instruments ======================= This example demonstrates how to use the ``show()`` method on various instrument objects like ``Camera`` and ``Radar`` to create visualisations. It also shows how to annotate plots with geographical positions. .. GENERATED FROM PYTHON SOURCE LINES 11-20 .. code-block:: Python from matplotlib import pyplot as plt from arguslib.camera.camera import Camera import datetime from arguslib.instruments.instruments import Position from arguslib.radar.radar import Radar dt = datetime.datetime(2025, 3, 25, 9) .. GENERATED FROM PYTHON SOURCE LINES 21-25 Plotting camera images ---------------------- Plotting images on a polar plot, with the axes aligned with the ordinal directions. .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: Python cam = Camera.from_config("COBALT", "3-7") cam.show(dt) .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_001.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 29-35 Annotating positions -------------------- We can annotate a position on the image. Here, we add a red dot at 10km altitude above Southampton, a pink dot 10km above Reading, and a dark red dot 10km above Chilbolton. .. GENERATED FROM PYTHON SOURCE LINES 35-66 .. code-block:: Python ax = cam.show(dt) cam.annotate_positions( [Position(-1.4419, 51.1553, 10.0)], dt, ax, marker="o", lw=0, color="darkred", label="Chilbolton", ) cam.annotate_positions( [Position(-1.4049, 50.9105, 10.0)], dt, ax, marker="o", lw=0, color="red", label="Southampton", ) cam.annotate_positions( [Position(-0.9783, 51.4550, 10.0)], dt, ax, marker="o", lw=0, color="pink", label="Reading", ) ax.legend(loc="upper left") .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_002.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 67-71 Controlling image orientation ----------------------------- We can also plot the image "unflipped", either by setting up the axes to be flipped: .. GENERATED FROM PYTHON SOURCE LINES 71-73 .. code-block:: Python cam.show(dt, theta_behaviour="unflipped_ordinal_aligned") .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_003.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 74-75 Or by setting the ``lr_flip`` argument to ``False``. .. GENERATED FROM PYTHON SOURCE LINES 75-80 .. code-block:: Python cam.show( dt, lr_flip=False, ) .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_004.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 81-83 We can set the theta behaviour to be "pixels", where the theta grid shows the major axes of the pixel grid. .. GENERATED FROM PYTHON SOURCE LINES 83-85 .. code-block:: Python cam.show(dt, theta_behaviour="pixels") .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_005.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 86-88 This lines up with the native image grid, which is seen when we plot on non-polar axes. .. GENERATED FROM PYTHON SOURCE LINES 88-91 .. code-block:: Python fig, ax = plt.subplots() cam.show(dt, ax=ax) .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_006.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 92-94 To still get the rotation, but in place of an existing non-polar set of axes, we can use the ``replace_ax`` argument. .. GENERATED FROM PYTHON SOURCE LINES 94-97 .. code-block:: Python fig, ax = plt.subplots() cam.show(dt, replace_ax=ax) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_007.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_007.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_008.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_008.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 98-101 The infrastructure can be rigged to plot in a way that doesn't make sense. Here, we set up a "bearing" axes, but then don't flip the axes, so the angles don't line up with the ordinal directions. .. GENERATED FROM PYTHON SOURCE LINES 101-107 .. code-block:: Python cam.show( dt, theta_behaviour="bearing", lr_flip=False, ) .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_009.png :alt: visualising instruments :srcset: /auto_examples/images/sphx_glr_visualising_instruments_009.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 108-115 Plotting radar data ------------------- Radar objects can also be plotted using the analogous ``show`` function. The axes don't have so much rotating and flipping to do. Following pyart default behaviour, the positive x direction is towards 0 degrees azimuth (i.e. south to north). .. GENERATED FROM PYTHON SOURCE LINES 115-119 .. code-block:: Python radar = Radar.from_config("COBALT") radar.show(datetime.datetime(2025, 5, 1, 7, 25, 6), var="DBZ") .. image-sg:: /auto_examples/images/sphx_glr_visualising_instruments_010.png :alt: ncas-mobile-ka-band-radar-1 220.9 Deg. 2025-05-01T07:25:06Z Equivalent reflectivity factor :srcset: /auto_examples/images/sphx_glr_visualising_instruments_010.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.082 seconds) .. _sphx_glr_download_auto_examples_visualising_instruments.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: visualising_instruments.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: visualising_instruments.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: visualising_instruments.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_