.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery_tutorials/measure_noise.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_tutorials_measure_noise.py: .. _tutorial_measure_noise: Measure noise of a FITS file ############################ Beginner's tutorial showing how to measure the noise of a `~madcubapy.io.MadcubaMap` object. For a detailed overview go to the :ref:`documentation page`. First we read the FITS file as a MadcubaMap object. .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python from madcubapy.io import MadcubaMap # Read fits file madcuba_map = MadcubaMap.read( "../examples/data/IRAS16293_SO_2-1_moment0_madcuba.fits") .. GENERATED FROM PYTHON SOURCE LINES 30-81 To measure the noise level of the map we have two options: * We can use the :func:`~madcubapy.operations.maps.measure_noise` function on the `~madcubapy.io.MadcubaMap` object to obtain the sigma value in a variable (this also works for `~astropy.nddata.CCDData` objects): .. code-block:: python sigma = measure_noise(madcuba_map) * Or we can use the :meth:`MadcubaMap.update_sigma() ` method to automatically store the measured sigma value in the FITS header, on the ``SIGMA`` card, and have it available for future analysis: .. code-block:: python madcuba_map.update_sigma() .. note:: Remember that changes applied to a `~madcubapy.io.MadcubaMap` object during a python run are not stored into the FITS file until the file is explicitly saved: .. code-block:: python madcuba_map.write("output_file.fits", overwrite=True) How it works ------------ Both options behave in the same way. A window will appear where the user can select polygons using the mouse: - Left clicks create polygon vertices. - Right click closes the current polygon, and a subsequent left click starts a new polygon. This window also offers buttons to change the statistic used to calculate the noise. Once we have the desired polygons, we can press the **Finish** button to close the window and return the noise value in a variable (the case of :func:`~madcubapy.operations.maps.measure_noise`) or stored in the FITS header (the case of :meth:`MadcubaMap.update_sigma() `). .. figure:: ../_static/figures/measure_noise.png :alt: Image with pcolor :figclass: align-center .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.015 seconds) .. _sphx_glr_download_gallery_tutorials_measure_noise.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: measure_noise.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: measure_noise.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: measure_noise.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_