<commit_before>Improved integrated intensity map
---------------------------------

Given the constrains on the First Look functions to keep things simple, the integrated intensity map of the NH\ :sub:`3` lines only include the emission from the main component.
As a solution, we have implemented a function that will use the results from the previous line fitting to determine the channel range with signal for the integrated intensity calculation.
The function `update_NH3_moment0` is within `PropertyMaps` and it will also create a new FITS file for each NH\ :sub:`3` integrated intensity map.

Here is an example of its usage:
    >>> import GAS
    >>> import GAS.PropertyMaps
    >>> GAS.PropertyMaps.update_NH3_moment0(region_name='OrionA', file_extension='_DR1', threshold=0.0125, save_masked=True)

In addition, the function will calculate the uncertainty at each pixel, since the channel range will depend on the line profile.

An example of the improvement in the integrated intensity map is 

.. figure:: figures/OrionA_NH3_11_TdV_FL.png
   :width: 250px
   :alt: TdV NH3(1,1) First Look
   
compared to the improved maps

.. figure:: figures/OrionA_NH3_11_TdV_QA.png
   :width: 250px
   :alt: TdV NH3(1,1) Improved maps
<commit_msg>More explanation on the method used for integrated intensity<commit_after>Improved integrated intensity map
---------------------------------
---------------------------------

Given the constrains on the First Look functions to keep things simple, the integrated intensity map of the NH\ :sub:`3` lines only include the emission from the main component.
As a solution, we have implemented a function that will use the results from the previous line fitting to determine the channel range with signal for the integrated intensity calculation.
The function `update_NH3_moment0` is within `PropertyMaps` and it will also create a new FITS file for each NH\ :sub:`3` integrated intensity map.

Here is an example of its usage:
    >>> import GAS
    >>> import GAS.PropertyMaps
    >>> GAS.PropertyMaps.update_NH3_moment0(region_name='OrionA', file_extension='_DR1', threshold=0.0125, save_masked=True)

Here the key parameter is the threshold used to identify the =0.0125

In addition, the function will calculate the uncertainty at each pixel, since the channel range will depend on the line profile.

Is it really better?
--------------------

Is this method really better than just selecting a fixed range of channels? Specially for the lower brightness lines. 

We have taken the OrionA map to better show the difference. Here, we show the NH\ :sub:`3` integrated intensity map generated by the first look pipeline with two different color ranges: *Left* panel shows the map with a wide color range to show the full dynamic range of the region, *Right* panel shows the map with a narrower color range to enhance the fainter emission.

.. figure:: figures/OrionA_NH3_11_TdV_FL.png
   :width: 350px
   :alt: TdV NH3(1,1) First Look
   
In comparison, similar color stretches are are shown for the improved inetgrated intensity maps, showing a much better noise level at the low brightness emission region:

.. figure:: figures/OrionA_NH3_11_TdV_QA.png
   :width: 350px
   :alt: TdV NH3(1,1) Improved maps


Also, we see that in some regions this works very well,

.. figure:: figures/OrionA_compare_spectra_pos0.png
   :width: 350px
   :alt: NH3(1,1) where it works


while in others the masking does not catch all the emission from faint components at different velocities.

   .. figure:: figures/OrionA_compare_spectra_pos1.png
   :width: 350px
   :alt: NH3(1,1) where it does not work very well
{'fraction_non_alphanumeric': 0.08948668679659622, 'fraction_numerical': 0.021959923140269007, 'mean_word_length': 3.8137384412153237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925550', 'n_tokens_mistral': 1041, 'n_tokens_neox': 971, 'n_words': 478}