.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_gallery/plot_monsoon_npwi.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_gallery_plot_monsoon_npwi.py: Onset and Retreat of Monsoon ========================================================================================================= Before proceeding with all the steps, first import some necessary libraries and packages .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import xarray as xr import cartopy.crs as ccrs import easyclimate as ecl .. GENERATED FROM PYTHON SOURCE LINES 13-14 Open precipitable water example data (must be **daily frequency** data) .. GENERATED FROM PYTHON SOURCE LINES 14-17 .. code-block:: Python pw_data = ecl.open_tutorial_dataset("pr_wtr_eatm_2022").pr_wtr pw_data .. raw:: html
<xarray.DataArray 'pr_wtr' (time: 365, lat: 73, lon: 144)> Size: 15MB
    [3836880 values with dtype=float32]
    Coordinates:
      * lat      (lat) float32 292B 90.0 87.5 85.0 82.5 ... -82.5 -85.0 -87.5 -90.0
      * lon      (lon) float32 576B 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5
      * time     (time) datetime64[ns] 3kB 2022-01-01 2022-01-02 ... 2022-12-31
    Attributes:
        long_name:     mean Daily Precipitable Water for entire atmosphere
        units:         kg/m^2
        precision:     2
        GRIB_id:       54
        GRIB_name:     PWAT
        var_desc:      Precipitable Water Content
        dataset:       NCEP Reanalysis Daily Averages
        level_desc:    Entire Atmosphere Considered As a Single Layer
        statistic:     Mean
        parent_stat:   Individual Obs
        valid_range:   [-50. 150.]
        actual_range:  [-4.8      81.075005]


.. GENERATED FROM PYTHON SOURCE LINES 18-19 Calculate the NPWI index using :py:func:`easyclimate.field.monsoon.calc_index_NPWI ` .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: Python NPWI_index = ecl.field.monsoon.calc_index_NPWI(pw_data) NPWI_index .. raw:: html
<xarray.DataArray 'pr_wtr' (time: 365, lat: 73, lon: 144)> Size: 15MB
    array([[[0.11188813, 0.11188813, 0.11188813, ..., 0.11188813,
             0.11188813, 0.11188813],
            [0.09598216, 0.0935412 , 0.09242763, ..., 0.10045148,
             0.09988777, 0.09955256],
            [0.09099708, 0.0909971 , 0.09108527, ..., 0.08562992,
             0.08699901, 0.08949416],
            ...,
            [0.484375  , 0.4631579 , 0.45161286, ..., 0.52763814,
             0.5177665 , 0.49230772],
            [0.5232558 , 0.51445085, 0.5058139 , ..., 0.5257143 ,
             0.52298856, 0.52298856],
            [0.57812494, 0.57812494, 0.57812494, ..., 0.57812494,
             0.57812494, 0.57812494]],

           [[0.13519815, 0.13519815, 0.13519815, ..., 0.13519815,
             0.13519815, 0.13519815],
            [0.10491072, 0.10022272, 0.09799556, ..., 0.10948082,
             0.10886644, 0.10738254],
            [0.10648596, 0.10745402, 0.10852714, ..., 0.09744094,
             0.10068426, 0.1040856 ],
    ...
            [0.42708334, 0.42105263, 0.4139785 , ..., 0.45226127,
             0.44162434, 0.43589744],
            [0.4127907 , 0.40462428, 0.40697673, ..., 0.3885714 ,
             0.39080462, 0.40229887],
            [0.40624997, 0.40624997, 0.40624997, ..., 0.40624997,
             0.40624997, 0.40624997]],

           [[0.1864802 , 0.1864802 , 0.1864802 , ..., 0.1864802 ,
             0.1864802 , 0.1864802 ],
            [0.1964286 , 0.19265033, 0.18708242, ..., 0.20541763,
             0.20314254, 0.19910516],
            [0.1577928 , 0.1568248 , 0.15600777, ..., 0.16043305,
             0.15933527, 0.15758753],
            ...,
            [0.41666666, 0.41578948, 0.40860215, ..., 0.40703517,
             0.41116747, 0.4051282 ],
            [0.37209302, 0.3699422 , 0.3837209 , ..., 0.34285712,
             0.3448276 , 0.36206898],
            [0.3359375 , 0.3359375 , 0.3359375 , ..., 0.3359375 ,
             0.3359375 , 0.3359375 ]]], shape=(365, 73, 144), dtype=float32)
    Coordinates:
      * lat      (lat) float32 292B 90.0 87.5 85.0 82.5 ... -82.5 -85.0 -87.5 -90.0
      * lon      (lon) float32 576B 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5
      * time     (time) datetime64[ns] 3kB 2022-01-01 2022-01-02 ... 2022-12-31
    Attributes:
        long_name:     mean Daily Precipitable Water for entire atmosphere
        units:         kg/m^2
        precision:     2
        GRIB_id:       54
        GRIB_name:     PWAT
        var_desc:      Precipitable Water Content
        dataset:       NCEP Reanalysis Daily Averages
        level_desc:    Entire Atmosphere Considered As a Single Layer
        statistic:     Mean
        parent_stat:   Individual Obs
        valid_range:   [-50. 150.]
        actual_range:  [-4.8      81.075005]


.. GENERATED FROM PYTHON SOURCE LINES 23-24 Separation of monsoon affected areas with :py:func:`easyclimate.field.monsoon.find_PW_monsoon_region ` .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python PW_monsoon_region = ecl.field.monsoon.find_PW_monsoon_region(pw_data) PW_monsoon_region .. raw:: html
<xarray.DataArray 'pr_wtr' (lat: 73, lon: 144)> Size: 11kB
    array([[False, False, False, ..., False, False, False],
           [False, False, False, ..., False, False, False],
           [False, False, False, ..., False, False, False],
           ...,
           [False, False, False, ..., False, False, False],
           [False, False, False, ..., False, False, False],
           [False, False, False, ..., False, False, False]], shape=(73, 144))
    Coordinates:
      * lat      (lat) float32 292B 90.0 87.5 85.0 82.5 ... -82.5 -85.0 -87.5 -90.0
      * lon      (lon) float32 576B 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5
    Attributes:
        long_name:     mean Daily Precipitable Water for entire atmosphere
        units:         kg/m^2
        precision:     2
        GRIB_id:       54
        GRIB_name:     PWAT
        var_desc:      Precipitable Water Content
        dataset:       NCEP Reanalysis Daily Averages
        level_desc:    Entire Atmosphere Considered As a Single Layer
        statistic:     Mean
        parent_stat:   Individual Obs
        valid_range:   [-50. 150.]
        actual_range:  [-4.8      81.075005]


.. GENERATED FROM PYTHON SOURCE LINES 28-29 Schematization of monsoon impact areas .. GENERATED FROM PYTHON SOURCE LINES 29-38 .. code-block:: Python fig, ax = ecl.plot.quick_draw_spatial_basemap(central_longitude = 200) PW_monsoon_region.plot( ax = ax, cbar_kwargs = {'location': 'bottom'}, transform = ccrs.PlateCarree(), levels = [0, 1], colors = ["grey"] ) .. image-sg:: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_001.png :alt: plot monsoon npwi :srcset: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 39-40 Calculation of monsoon onset with :py:func:`easyclimate.field.monsoon.calc_NPWI_monsoon_onset ` .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python monsoon_onset_date = ecl.field.monsoon.calc_NPWI_monsoon_onset(NPWI_index) monsoon_onset_date .. raw:: html
<xarray.DataArray (lat: 71, lon: 142)> Size: 81kB
    array([[199., 199., 199., ..., 198., 198., 198.],
           [199., 199., 199., ..., 199., 199., 199.],
           [199., 199., 199., ..., 199., 199., 199.],
           ...,
           [ nan,  nan,  22., ...,  nan,  nan,  nan],
           [ nan,  nan,  nan, ...,  nan,  nan,  nan],
           [ nan,  nan,  nan, ...,  nan,  nan,  nan]], shape=(71, 142))
    Coordinates:
      * lat      (lat) float32 284B 87.5 85.0 82.5 80.0 ... -80.0 -82.5 -85.0 -87.5
      * lon      (lon) float32 568B 2.5 5.0 7.5 10.0 ... 347.5 350.0 352.5 355.0


.. GENERATED FROM PYTHON SOURCE LINES 44-45 Analyzing and mapping the monsoon onset time in the monsoon impact area .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python fig, ax = ecl.plot.quick_draw_spatial_basemap(central_longitude = 180) monsoon_onset_date.where(PW_monsoon_region).plot( ax = ax, cbar_kwargs = {'location': 'bottom'}, transform = ccrs.PlateCarree(), cmap = 'Reds' ) .. image-sg:: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_002.png :alt: plot monsoon npwi :srcset: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 54-55 Calculation of monsoon retreat time with :py:func:`easyclimate.field.monsoon.calc_NPWI_monsoon_retreat ` .. GENERATED FROM PYTHON SOURCE LINES 55-58 .. code-block:: Python monsoon_retreat_date = ecl.field.monsoon.calc_NPWI_monsoon_retreat(NPWI_index, monsoon_onset_date) monsoon_retreat_date .. raw:: html
<xarray.DataArray (lat: 71, lon: 142)> Size: 81kB
    array([[218., 218., 218., ..., 218., 218., 218.],
           [217., 222., 222., ..., 215., 215., 215.],
           [218., 222., 222., ..., 203., 216., 217.],
           ...,
           [ nan,  nan,  28., ...,  nan,  nan,  nan],
           [ nan,  nan,  nan, ...,  nan,  nan,  nan],
           [ nan,  nan,  nan, ...,  nan,  nan,  nan]], shape=(71, 142))
    Coordinates:
      * lat      (lat) float32 284B 87.5 85.0 82.5 80.0 ... -80.0 -82.5 -85.0 -87.5
      * lon      (lon) float32 568B 2.5 5.0 7.5 10.0 ... 347.5 350.0 352.5 355.0


.. GENERATED FROM PYTHON SOURCE LINES 59-60 Analyzing and mapping the monsoon retreat time in the monsoon impact area .. GENERATED FROM PYTHON SOURCE LINES 60-68 .. code-block:: Python fig, ax = ecl.plot.quick_draw_spatial_basemap(central_longitude = 180) monsoon_retreat_date.where(PW_monsoon_region).plot( ax = ax, cbar_kwargs = {'location': 'bottom'}, transform = ccrs.PlateCarree(), cmap = 'Reds' ) .. image-sg:: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_003.png :alt: plot monsoon npwi :srcset: /auto_gallery/images/sphx_glr_plot_monsoon_npwi_003.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 9.400 seconds) .. _sphx_glr_download_auto_gallery_plot_monsoon_npwi.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_monsoon_npwi.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_monsoon_npwi.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_monsoon_npwi.zip `