Demo Python code for Large Scale Precipitation Tracking (LPT)¶

In [ ]:
import numpy as np
import datetime as dt
import pandas as pd
import xarray as xr
import matplotlib as mpl  # Needed to access mpl.colormaps[cmapname]
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

1. Reading in and plotting the centroid tracks¶

The centroid track information is contained in the NetCDF track files. The tracks are saved as stitched latitude (centroid_lat_stitched) and longitude (centroid_lat_stitched) data. In the stitched data, the individual system tracks are separated by NaN values. The track times (datetime_stitched) and areas (area_stitched) are stitched in the same manner.

  • To plot all the tracks at once, just plot lon vs. lat for a map or lon vs. time for a time-longitude plot. The individual systems are broken up by the NaN values.
  • To extract information for a specific LPT system, use the variable lptid_stitched.
In [ ]:
# Read in tracks for a year of LPT.
fn_lpt_systems = ('data/imerg/g50_72h/thresh12/systems/'
                  + 'lpt_systems_imerg_2022060100_2023063023.nc')
lpt_systems = xr.load_dataset(fn_lpt_systems)
lpt_systems
Out[ ]:
<xarray.Dataset>
Dimensions:                               (nlpt: 108, nstitch: 51707, nobj: 1615)
Coordinates:
  * nlpt                                  (nlpt) int32 0 1 2 3 ... 105 106 107
  * nstitch                               (nstitch) int32 0 1 2 ... 51705 51706
  * nobj                                  (nobj) int32 0 1 2 ... 1612 1613 1614
Data variables: (12/38)
    lptid                                 (nlpt) float64 0.1 1.1 ... 60.2 61.1
    lpt_begin_index                       (nlpt) int64 1 177 598 ... 51295 51526
    lpt_end_index                         (nlpt) int64 175 596 ... 51524 51705
    centroid_lon_start                    (nlpt) float64 264.9 298.4 ... 204.1
    centroid_lat_start                    (nlpt) float64 13.69 -12.56 ... -23.2
    centroid_lon_end                      (nlpt) float64 290.1 261.9 ... 206.4
    ...                                    ...
    min_filtered_running_field            (nstitch) float64 nan 12.0 ... nan
    max_inst_field                        (nstitch) float64 nan 40.38 ... nan
    max_running_field                     (nstitch) float64 nan 196.9 ... nan
    max_filtered_running_field            (nstitch) float64 nan 18.93 ... nan
    num_objects                           (nlpt) int32 175 420 723 ... 230 180
    objid                                 (nlpt, nobj) float64 2.022e+13 ... nan
Attributes:
    description:  LPT Systems NetCDF file.
xarray.Dataset
    • nlpt: 108
    • nstitch: 51707
    • nobj: 1615
    • nlpt
      (nlpt)
      int32
      0 1 2 3 4 5 ... 103 104 105 106 107
      units :
      1
      array([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,
              14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,
              28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,
              42,  43,  44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,
              56,  57,  58,  59,  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
              70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
              84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,  96,  97,
              98,  99, 100, 101, 102, 103, 104, 105, 106, 107], dtype=int32)
    • nstitch
      (nstitch)
      int32
      0 1 2 3 ... 51703 51704 51705 51706
      units :
      1
      array([    0,     1,     2, ..., 51704, 51705, 51706], dtype=int32)
    • nobj
      (nobj)
      int32
      0 1 2 3 4 ... 1611 1612 1613 1614
      units :
      1
      array([   0,    1,    2, ..., 1612, 1613, 1614], dtype=int32)
    • lptid
      (nlpt)
      float64
      0.1 1.1 2.1 2.2 ... 60.1 60.2 61.1
      units :
      1.0
      long_name :
      LPT System id
      array([ 0.1 ,  1.1 ,  2.1 ,  2.2 ,  2.3 ,  2.4 ,  2.5 ,  2.6 ,  2.7 ,
              2.8 ,  2.9 ,  3.1 ,  4.1 ,  4.2 ,  5.1 ,  6.1 ,  7.1 ,  8.1 ,
              8.2 ,  9.1 ,  9.2 , 10.1 , 11.1 , 12.1 , 13.1 , 14.1 , 15.1 ,
             16.1 , 17.1 , 18.1 , 19.1 , 20.1 , 21.1 , 21.2 , 21.3 , 21.4 ,
             21.5 , 21.6 , 21.7 , 21.8 , 21.9 , 22.1 , 23.1 , 24.1 , 24.2 ,
             25.1 , 26.1 , 27.1 , 28.1 , 29.1 , 29.2 , 29.3 , 29.4 , 30.1 ,
             31.1 , 32.1 , 33.1 , 34.1 , 35.1 , 36.1 , 37.01, 37.02, 37.03,
             37.04, 37.05, 37.06, 37.07, 37.08, 37.09, 37.1 , 37.11, 37.12,
             37.13, 37.14, 37.15, 37.16, 37.17, 37.18, 37.19, 38.1 , 38.2 ,
             39.1 , 40.1 , 41.1 , 42.1 , 43.1 , 44.1 , 44.2 , 44.3 , 45.1 ,
             46.1 , 47.1 , 48.1 , 49.1 , 49.2 , 50.1 , 51.1 , 52.1 , 53.1 ,
             54.1 , 55.1 , 56.1 , 57.1 , 58.1 , 59.1 , 60.1 , 60.2 , 61.1 ])
    • lpt_begin_index
      (nlpt)
      int64
      1 177 598 ... 51093 51295 51526
      units :
      1
      long_name :
      LPT System beginning index (zero-based, Python convention)
      array([    1,   177,   598,  1166,  1822,  2407,  2867,  3415,  3892,
              4319,  4834,  5278,  5457,  6236,  6884,  7016,  7220,  7474,
              7666,  7940,  8301,  8710,  8908,  9081,  9346,  9536,  9716,
             10086, 10281, 10586, 10800, 11029, 11199, 11838, 12995, 13426,
             14375, 14903, 15172, 16223, 17792, 18061, 18367, 18576, 18821,
             19006, 19206, 19380, 19639, 20012, 20969, 22064, 22552, 23149,
             23339, 23553, 24393, 24814, 25129, 25361, 25831, 26166, 27417,
             28811, 29689, 30425, 31520, 32758, 33480, 34060, 34913, 35909,
             36389, 36727, 37608, 38632, 39140, 39506, 39822, 40281, 40787,
             40917, 41087, 41491, 41930, 42657, 43091, 43934, 44546, 45436,
             45607, 45950, 46198, 46788, 47233, 48122, 48444, 48653, 48921,
             49094, 49293, 49674, 50006, 50420, 50840, 51093, 51295, 51526])
    • lpt_end_index
      (nlpt)
      int64
      175 596 1164 ... 51293 51524 51705
      units :
      1
      long_name :
      LPT System ending index (zero-based, Python convention)
      array([  175,   596,  1164,  1820,  2405,  2865,  3413,  3890,  4317,
              4832,  5276,  5455,  6234,  6882,  7014,  7218,  7472,  7664,
              7938,  8299,  8708,  8906,  9079,  9344,  9534,  9714, 10084,
             10279, 10584, 10798, 11027, 11197, 11836, 12993, 13424, 14373,
             14901, 15170, 16221, 17790, 18059, 18365, 18574, 18819, 19004,
             19204, 19378, 19637, 20010, 20967, 22062, 22550, 23147, 23337,
             23551, 24391, 24812, 25127, 25359, 25829, 26164, 27415, 28809,
             29687, 30423, 31518, 32756, 33478, 34058, 34911, 35907, 36387,
             36725, 37606, 38630, 39138, 39504, 39820, 40279, 40785, 40915,
             41085, 41489, 41928, 42655, 43089, 43932, 44544, 45434, 45605,
             45948, 46196, 46786, 47231, 48120, 48442, 48651, 48919, 49092,
             49291, 49672, 50004, 50418, 50838, 51091, 51293, 51524, 51705])
    • centroid_lon_start
      (nlpt)
      float64
      264.9 298.4 133.5 ... 91.02 204.1
      units :
      degrees_east
      long_name :
      starting longitude (0-360)
      standard_name :
      longitude
      array([264.87798633, 298.44829434, 133.54631309, 133.54631309,
             133.54631309,  85.91442916,  85.91442916,  85.91442916,
              63.41018398,  63.41018398,  63.41018398, 144.47854259,
              66.93761735, 142.74898238, 343.29780996, 272.49203179,
             291.86942424,  97.12735815, 137.29952693, 131.43546763,
              87.24813278, 160.00509571, 357.38203802, 261.05124077,
             132.21337565, 153.32930031, 113.9831724 , 298.38842988,
             264.86111209, 142.34445192, 305.1474526 ,  97.35626469,
             164.9026462 , 164.9026462 ,  93.56717789,  93.56717789,
             160.1898706 , 160.1898706 , 160.1898706 , 160.1898706 ,
             146.54337991, 286.71217638, 299.74176382, 306.41704515,
             286.98920271, 169.31832789, 219.51087736, 317.11635191,
             139.89183824, 114.8487026 , 114.8487026 , 114.8487026 ,
             114.8487026 , 304.36425844, 181.62523223, 305.59611129,
              27.93553668,  30.08748178, 216.36390185,  76.18666844,
             217.21045985, 145.49801374, 145.49801374, 145.49801374,
             145.49801374,  91.77879909,  91.77879909,  91.77879909,
              91.77879909, 202.77236803, 202.77236803, 202.77236803,
             202.77236803, 132.05140259, 132.05140259, 132.05140259,
             132.05140259, 191.87676388, 191.87676388, 318.15863692,
             318.15863692,  35.92924971, 292.43058189,  20.68682166,
             289.99423818,  41.1674298 ,  80.65962064,  80.65962064,
              80.65962064, 299.59199174, 294.1824324 ,   3.70651139,
              93.14198003, 154.36378926, 154.36378926, 205.24205012,
             123.69055503, 278.02056305, 290.34103108, 252.93249173,
              62.8686816 ,  89.4285249 , 138.57687965, 137.14376774,
             249.58336291, 111.37922297,  91.0178811 , 204.11091005])
    • centroid_lat_start
      (nlpt)
      float64
      13.69 -12.56 -5.303 ... 20.83 -23.2
      units :
      degrees_north
      long_name :
      starting latitude (-90-90)
      standard_name :
      longitude
      array([ 13.68680658, -12.55953742,  -5.3026228 ,  -5.3026228 ,
              -5.3026228 ,  26.31486253,  26.31486253,  26.31486253,
               4.02750678,   4.02750678,   4.02750678, -22.09959478,
               2.71349452,  15.60333373,  10.17883172,   8.21850129,
               4.06212601,  15.59037854,   6.51385677,  14.51797171,
              -5.13582228,  22.54046838,  10.51538162,  11.56816525,
              20.62573742,  21.31750349,   1.43382765,  18.59131805,
              12.54004048,  20.22359661,  15.59161805,  -4.65019193,
               7.41392832,   7.41392832,   5.43949372,   5.43949372,
              13.23252293,  13.23252293,  13.23252293,  13.23252293,
              -1.00389433,  10.85520565,   8.81394351,  -9.39592149,
               3.67266405, -17.34906463, -19.58929795, -23.04381141,
             -13.35504259,   4.00657236,   4.00657236,   4.00657236,
               4.00657236,  27.178941  , -16.90566192, -13.42146215,
             -18.62442787, -18.70145262, -28.22281533,  -5.74273831,
             -30.85405915, -17.36389696, -17.36389696, -17.36389696,
             -17.36389696,  -5.06959774,  -5.06959774,  -5.06959774,
              -5.06959774, -25.31567829, -25.31567829, -25.31567829,
             -25.31567829, -21.02265887, -21.02265887, -21.02265887,
             -21.02265887, -12.98275541, -12.98275541, -22.15255864,
             -22.15255864, -12.54800793,  -5.83487848,  -4.15318361,
              -3.39001687, -19.46304076,  -5.66381583,  -5.66381583,
              -5.66381583, -22.67074187,  -3.14498111,   1.5604668 ,
              -1.49550722,   5.1667175 ,   5.1667175 , -17.87890786,
              34.10672115,   3.91485012,  23.14140291,   6.34554849,
               3.51376521,  10.03810035,   9.55456181,   1.87494723,
               8.58107359,  26.58626218,  20.83401845, -23.20271191])
    • centroid_lon_end
      (nlpt)
      float64
      290.1 261.9 164.0 ... 74.31 206.4
      units :
      degrees_east
      long_name :
      ending longitude (0-360)
      standard_name :
      longitude
      array([290.11375956, 261.86379743, 164.01439161, 138.6722078 ,
              80.06594906, 164.01439161, 138.6722078 ,  80.06594906,
             164.01439161, 138.6722078 ,  80.06594906, 166.1449985 ,
              69.679826  ,  69.679826  , 335.49414543, 291.13106995,
             276.89695131,  90.6268527 ,  90.6268527 ,  96.55115465,
              96.55115465, 149.67817931, 353.39919368, 248.64958715,
             132.52708816, 128.6594842 ,  85.76963832, 310.68826849,
             261.54525087, 138.06665509, 297.51275771,  85.81538431,
             121.15634319, 121.27829238, 121.15634319, 121.27829238,
              94.04376021, 163.1983501 , 121.15634319, 121.27829238,
             121.27829238, 301.97472429, 268.74045578, 298.98689814,
             298.98689814, 188.69132818, 227.55234859, 303.29382759,
             134.08690148, 168.33548766, 125.31226093,  91.39157634,
             154.70482054, 335.22750566, 188.81300786, 291.19791247,
              20.46962725,  27.16128653, 189.44249049,  47.00376743,
             224.18966745, 111.69361299, 224.18966745, 165.9954038 ,
             101.71185027, 111.69361299, 224.18966745, 165.9954038 ,
             101.71185027, 111.69361299, 224.18966745, 165.9954038 ,
             101.71185027, 111.69361299, 224.18966745, 165.9954038 ,
             101.71185027, 111.69361299, 224.18966745, 296.31463644,
             322.08719331,  33.02979746, 293.22788169,  78.82917509,
             296.88016276,  28.38888061, 229.60342651, 126.86305395,
             166.93092903, 305.73335906, 306.94247067,   2.14528916,
              73.01983164, 179.67795088, 147.57375544, 227.0030676 ,
             161.68327739, 289.49584163, 289.22051747, 288.9970385 ,
              67.26417341,  91.4747527 , 131.09747592, 168.08070242,
             256.57964806,  74.30573446,  74.30573446, 206.38728477])
    • centroid_lat_end
      (nlpt)
      float64
      31.63 8.838 3.553 ... 21.33 -37.85
      units :
      degrees_north
      long_name :
      ending latitude (-90-90)
      standard_name :
      longitude
      array([ 31.63233846,   8.83780689,   3.55291988,   0.58575154,
              19.5993255 ,   3.55291988,   0.58575154,  19.5993255 ,
               3.55291988,   0.58575154,  19.5993255 , -33.28025604,
              25.03485164,  25.03485164,   9.28763893,   3.10812351,
               8.68284979,  19.93809321,  19.93809321, -10.03864872,
             -10.03864872,  22.684243  ,  12.15382211,  21.83386025,
              42.71431844,  17.77044104,  18.08304552,  47.5445799 ,
              13.58990092,  38.11433211,  46.82963951, -11.02471236,
              22.84551678, -12.04692248,  22.84551678, -12.04692248,
             -19.82426383,  47.75340427,  22.84551678, -12.04692248,
             -12.04692248,  38.52367288,  22.2061712 ,   6.31730084,
               6.31730084, -18.06910545, -25.53702682,  -1.39708304,
              20.96711024, -19.50320228,  11.56774041, -13.30434149,
              23.31932497,  48.47047397, -11.3563014 ,  -4.00699963,
             -12.12343435, -12.8496054 , -12.07431045, -31.02663779,
             -17.8967113 ,   0.96689919, -17.8967113 ,  -8.62458634,
             -12.05142139,   0.96689919, -17.8967113 ,  -8.62458634,
             -12.05142139,   0.96689919, -17.8967113 ,  -8.62458634,
             -12.05142139,   0.96689919, -17.8967113 ,  -8.62458634,
             -12.05142139,   0.96689919, -17.8967113 ,  -7.91629763,
             -23.78571395, -13.96145707,  -2.4137485 , -25.04673604,
              -5.93629359,  -6.73685607, -26.78377784, -23.82387037,
               6.65760238,  -6.60014713,   1.3522681 ,   0.89564109,
              -9.85995592, -12.6913319 ,  39.45277191, -22.09376323,
              31.76651234,   4.13366025,  30.27811511,  23.79711353,
              21.48721309,  24.50006411,  28.96576828,   1.15393581,
              13.96911984,  21.33083101,  21.33083101, -37.85307769])
    • duration
      (nlpt)
      timedelta64[ns]
      7 days 06:00:00 ... 7 days 11:00:00
      long_name :
      LPT System Duration
      array([ 626400000000000, 1508400000000000, 2037600000000000,
             2354400000000000, 2098800000000000, 1648800000000000,
             1965600000000000, 1710000000000000, 1530000000000000,
             1846800000000000, 1591200000000000,  637200000000000,
             2797200000000000, 2325600000000000,  604800000000000,
              727200000000000, 1296000000000000,  684000000000000,
              979200000000000, 1292400000000000, 1465200000000000,
              741600000000000,  766800000000000,  946800000000000,
              676800000000000,  640800000000000, 1396800000000000,
              694800000000000, 1090800000000000,  763200000000000,
              817200000000000,  604800000000000, 2293200000000000,
             4158000000000000, 1544400000000000, 3409200000000000,
             1893600000000000,  961200000000000, 3776400000000000,
             5641200000000000,  961200000000000, 1094400000000000,
              745200000000000,  874800000000000,  658800000000000,
              712800000000000,  619200000000000,  925200000000000,
             1335600000000000, 3438000000000000, 3934800000000000,
             1749600000000000, 2142000000000000,  676800000000000,
              763200000000000, 3182400000000000, 1508400000000000,
             1126800000000000,  828000000000000, 1684800000000000,
             1198800000000000, 4496400000000000, 5011200000000000,
             3153600000000000, 2642400000000000, 3934800000000000,
             4449600000000000, 2592000000000000, 2080800000000000,
             3063600000000000, 3578400000000000, 1720800000000000,
             1209600000000000, 3164400000000000, 3679200000000000,
             1821600000000000, 1310400000000000, 1130400000000000,
             1645200000000000, 1814400000000000,  460800000000000,
              604800000000000, 1497600000000000, 1706400000000000,
             2610000000000000, 1666800000000000, 3027600000000000,
             2196000000000000, 3196800000000000,  608400000000000,
             1227600000000000,  885600000000000, 2116800000000000,
             1674000000000000, 3272400000000000, 1152000000000000,
              792000000000000, 1162800000000000,  615600000000000,
              709200000000000, 1364400000000000, 1188000000000000,
             1483200000000000, 1504800000000000,  903600000000000,
              720000000000000,  824400000000000,  644400000000000],
            dtype='timedelta64[ns]')
    • maxarea
      (nlpt)
      float64
      3.562e+06 5.696e+06 ... 3.437e+06
      units :
      km2
      long_name :
      LPT System area at time of largest extent
      array([ 3562363.75 ,  5695748.   , 12678694.   , 12678694.   ,
             12678694.   , 12678694.   , 12678694.   , 12678694.   ,
             12678694.   , 12678694.   , 12678694.   ,  4422325.   ,
             11978039.   , 11978039.   ,  1759852.875,  3485462.25 ,
              2955381.   ,  3790814.25 ,  3790814.25 ,  6820391.5  ,
              6820391.5  ,  2030473.   ,  3028665.5  ,  5132849.5  ,
              4416309.5  ,  1832494.   ,  8201933.5  ,  2380466.25 ,
              6331172.   ,  6130107.5  ,  3874474.25 ,  1497356.125,
             10965465.   , 10965465.   , 10181180.   , 10181180.   ,
             10773331.   ,  9326331.   , 10965465.   , 10965465.   ,
              9318595.   ,  4046737.5  ,  4112577.5  ,  5961861.   ,
              5961861.   ,  3969068.25 ,  2392353.5  ,  4148344.75 ,
              7886361.5  , 16645152.   , 16645152.   ,  9223572.   ,
              9223572.   ,  3471888.75 ,  5642549.   ,  7081306.5  ,
              3934538.25 ,  2265318.25 ,  2848826.75 ,  5300573.5  ,
             13951444.   , 15366792.   , 15366792.   , 14821906.   ,
             13670553.   , 15366792.   , 15366792.   , 14821906.   ,
             13670553.   , 15366792.   , 15366792.   , 14821906.   ,
             13670553.   , 15366792.   , 15366792.   , 14821906.   ,
             13670553.   , 15366792.   , 15366792.   ,  6678641.   ,
              2586925.25 ,  3183480.25 ,  9603139.   ,  5642347.5  ,
             10196472.   ,  2951914.5  ,  9248585.   ,  9248585.   ,
              9248585.   ,  6573426.   ,  8543704.   ,  4177834.25 ,
              8372850.5  , 10153264.   , 10153264.   ,  2491213.25 ,
              1395535.25 ,  5477188.5  ,  1504848.5  ,  7300395.   ,
              2532231.25 ,  4754574.   ,  5608585.5  ,  7729627.5  ,
              5918275.5  ,  3799522.   ,  3799522.   ,  3436510.   ])
    • zonal_propagation_speed
      (nlpt)
      float64
      4.069 -2.18 1.123 ... -1.994 0.9802
      units :
      m s-1
      long_name :
      Centroid Zonal Propagation Speed from least squares regression.
      array([  4.06888554,  -2.17998965,   1.12310357,   0.31863112,
              -3.16969844,   5.2352905 ,   3.02617419,  -1.06794116,
               7.70796808,   4.62205003,   0.48461973,   3.22991099,
               0.34461709,  -4.00888289,  -1.32854347,   3.84229232,
              -1.03045935,  -0.163725  ,  -6.45654831,  -3.57878323,
               0.1000013 ,  -1.85086186,  -1.89017452,  -0.50627854,
               0.14772008,  -4.34593458,  -1.4445075 ,   2.2068914 ,
              -0.48617858,  -0.95865609,  -0.51540499,  -2.26148642,
              -1.88994528,  -0.83446179,   2.50930493,   0.52080929,
              -4.58862003,  -0.88078001,  -0.56462229,  -0.45088039,
              -2.55891265,   2.31392422,  -4.78425883,  -1.32063838,
               4.46314794,   2.94818828,   1.57364114,  -2.27900831,
              -1.18377482,   2.54220492,   1.14962083,  -0.2582935 ,
               3.21043925,   4.31363612,   2.44920942,  -0.34932259,
              -1.03418496,  -0.3382705 ,  -3.51004313,  -2.77090052,
               0.67063574,  -0.36690876,   1.53438724,   1.1770995 ,
              -2.17636685,   0.64070178,   2.76533681,   4.21899922,
               0.703543  ,  -2.7471628 ,   1.20400302,  -0.96042974,
             -11.53759837,  -0.96507079,   2.38486781,   3.40113763,
              -3.51831286, -11.14741178,   4.16723109,  -0.72064613,
               2.22452173,  -1.29023016,   0.36380228,   4.42297836,
               0.43426324,  -0.60945072,   5.03211203,   2.78768658,
               3.16541019,   2.7962319 ,   0.27482321,   0.99638862,
               0.15478926,   0.96833112,  -0.32139868,   3.43609575,
               5.20471465,   1.08438442,  -0.97856569,   6.98484633,
               0.31164759,  -0.44042804,  -0.83632854,   2.37479957,
               0.75382146,  -8.32004963,  -1.99434405,   0.98022939])
    • meridional_propagation_speed
      (nlpt)
      float64
      4.018 0.7887 ... 0.06265 -2.693
      units :
      m s-1
      long_name :
      Centroid Meridional Propagation Speed from least squares regression.
      array([ 4.01841026,  0.78871916, -0.05585772, -0.3388978 ,  0.77549869,
             -1.57064183, -1.49905575, -0.30058916, -0.10122277, -0.43861311,
              1.22378622, -1.32847361,  1.07909508,  0.29480843, -0.13028398,
             -1.19626546,  0.31970356,  0.22230281,  1.9770699 , -2.61496591,
             -0.17892234, -0.04209468,  0.34429442,  0.78674786,  3.6203129 ,
             -1.13939443,  1.07620381,  5.06872056,  0.01956169,  2.74105865,
              4.69474435, -1.32831874, -0.077351  , -0.55060523,  1.00722581,
             -0.3970939 , -1.93893148,  4.5332042 , -0.0268876 , -0.34781985,
             -1.84892475,  3.2640519 ,  2.34966485,  2.91263409, -0.80945125,
              0.063336  , -1.51913403,  1.5609786 ,  3.74544617, -0.90213594,
              0.16558712, -1.25810079,  0.44258485,  2.82829137,  1.14009579,
              0.20607433,  0.86842826,  0.45889233,  2.37792447, -1.53870123,
              1.11990355,  0.22124109, -0.25448198, -0.26081517,  0.08685105,
              0.02614954, -0.51386481, -0.90120709, -0.7195671 ,  0.58992284,
             -0.33542946,  0.03433788,  1.24284285,  0.5986435 , -0.28923453,
              0.07552985,  1.19011682,  1.79521249, -1.14260682,  0.43958861,
             -1.80291469,  0.00548827, -0.11885365, -1.09785571, -0.04715339,
              0.88391931, -0.76349118, -0.4253341 ,  0.37191773,  1.76768632,
              0.65228331,  0.39285888, -0.20442769, -1.20705107,  0.84369381,
             -0.13488082, -0.80291147, -0.31734213,  0.87255298,  3.33962623,
              1.49216816,  1.21303158,  1.61807126,  0.03852141,  0.68311155,
             -1.05063157,  0.0626521 , -2.69280744])
    • timestamp_stitched
      (nstitch)
      datetime64[ns]
      2022-06-01 ... 2023-06-30T23:00:00
      long_name :
      LPT System time stamp -- stitched
      array(['2022-06-01T00:00:00.000000000', '2022-06-01T00:00:00.000000000',
             '2022-06-01T01:00:00.000000000', ...,
             '2023-06-30T22:00:00.000000000', '2023-06-30T23:00:00.000000000',
             '2023-06-30T23:00:00.000000000'], dtype='datetime64[ns]')
    • lptid_stitched
      (nstitch)
      float64
      nan 0.1 0.1 0.1 ... 61.1 61.1 nan
      units :
      1.0
      long_name :
      LPT System id -- stitched
      array([ nan,  0.1,  0.1, ..., 61.1, 61.1,  nan])
    • nobj_stitched
      (nstitch)
      int32
      -2147483648 1 1 ... 1 1 -2147483648
      array([-2147483648,           1,           1, ...,           1,
                       1, -2147483648], dtype=int32)
    • centroid_lon_stitched
      (nstitch)
      float64
      nan 264.9 265.1 ... 206.4 206.4 nan
      units :
      degrees_east
      long_name :
      centroid longitude, may be inbetween objects (0-360) -- stitched
      standard_name :
      longitude
      array([         nan, 264.87798633, 265.11245195, ..., 206.39385198,
             206.38728477,          nan])
    • centroid_lat_stitched
      (nstitch)
      float64
      nan 13.69 13.7 ... -37.85 nan
      units :
      degrees_north
      long_name :
      centroid latitude, may be inbetween objects (-90-90) -- stitched
      standard_name :
      latitude
      array([         nan,  13.68680658,  13.69958882, ..., -37.74802505,
             -37.85307769,          nan])
    • largest_object_centroid_lon_stitched
      (nstitch)
      float64
      nan 264.9 265.1 ... 206.4 206.4 nan
      units :
      degrees_east
      long_name :
      centroid longitude of the largest contiguous object (0-360) -- stitched
      standard_name :
      longitude
      array([         nan, 264.87799072, 265.11245728, ..., 206.3938446 ,
             206.38728333,          nan])
    • largest_object_centroid_lat_stitched
      (nstitch)
      float64
      nan 13.69 13.7 ... -37.85 nan
      units :
      degrees_north
      long_name :
      centroid latitude of the largest contiguous object (-90-90) -- stitched
      standard_name :
      latitude
      array([         nan,  13.68680668,  13.69958878, ..., -37.74802399,
             -37.85307693,          nan])
    • area_stitched
      (nstitch)
      float64
      nan 3.026e+06 ... 3.437e+06 nan
      units :
      km2
      long_name :
      LPT System enclosed area -- stitched
      array([       nan, 3025630.25, 3029482.75, ..., 3373442.5 , 3436510.  ,
                    nan])
    • max_lon_stitched
      (nstitch)
      float64
      nan 276.9 277.0 ... 218.6 218.6 nan
      units :
      degrees_east
      long_name :
      max (eastmost) longitude (0-360) -- stitched
      standard_name :
      longitude
      array([         nan, 276.8500061 , 276.95001221, ..., 218.55000305,
             218.55000305,          nan])
    • max_lat_stitched
      (nstitch)
      float64
      nan 20.75 20.85 ... -27.45 nan
      units :
      degrees_north
      long_name :
      max (northmost) latitude (-90-90) -- stitched
      standard_name :
      longitude
      array([         nan,  20.75      ,  20.85000038, ..., -27.54999924,
             -27.45000076,          nan])
    • min_lon_stitched
      (nstitch)
      float64
      nan 249.8 250.1 ... 195.8 195.8 nan
      units :
      degrees_east
      long_name :
      min (westmost) longitude (0-360) -- stitched
      standard_name :
      longitude
      array([        nan, 249.75     , 250.1499939, ..., 195.75     ,
             195.75     ,         nan])
    • min_lat_stitched
      (nstitch)
      float64
      nan 7.85 7.85 ... -49.95 -49.95 nan
      units :
      degrees_north
      long_name :
      min (southmost) latitude (-90-90) -- stitched
      standard_name :
      longitude
      array([         nan,   7.8499999 ,   7.8499999 , ..., -49.95000076,
             -49.95000076,          nan])
    • westmost_lat_stitched
      (nstitch)
      float64
      nan 11.05 11.1 ... -37.8 -37.8 nan
      units :
      degrees_north
      long_name :
      Latitude at min (westmost) longitude (-90-90) -- stitched
      standard_name :
      longitude
      array([         nan,  11.05000019,  11.09999943, ..., -37.79999924,
             -37.79999924,          nan])
    • eastmost_lat_stitched
      (nstitch)
      float64
      nan 17.35 17.4 ... -38.0 -38.0 nan
      units :
      degrees_north
      long_name :
      Latitude at max (eastmost) longitude (-90-90) -- stitched
      standard_name :
      longitude
      array([         nan,  17.35000038,  17.39999962, ..., -38.        ,
             -38.        ,          nan])
    • southmost_lon_stitched
      (nstitch)
      float64
      nan 263.6 264.2 ... 206.2 206.1 nan
      units :
      degrees_east
      long_name :
      Longitude at min (southmost) longitude (0-360) -- stitched
      standard_name :
      latitude
      array([         nan, 263.6000061 , 264.25      , ..., 206.15000916,
             206.1499939 ,          nan])
    • northmost_lon_stitched
      (nstitch)
      float64
      nan 273.5 273.7 ... 201.6 201.7 nan
      units :
      degrees_east
      long_name :
      Longitude at max (northmost) longitude (0-360) -- stitched
      standard_name :
      latitude
      array([         nan, 273.54998779, 273.70001221, ..., 201.6499939 ,
             201.65000916,          nan])
    • amean_inst_field
      (nstitch)
      float64
      nan 1.17 1.221 ... 0.4691 nan
      units :
      mm h-1
      long_name :
      LP object mean instantaneous rain rate (at end of running time).
      array([       nan, 1.16969919, 1.22102082, ..., 0.46639779, 0.46913002,
                    nan])
    • amean_running_field
      (nstitch)
      float64
      nan 22.28 22.14 ... 16.86 16.85 nan
      units :
      mm day-1
      long_name :
      LP object running mean, mean rain rate (at end of running time).
      array([        nan, 22.27923521, 22.14330351, ..., 16.85912951,
             16.85426319,         nan])
    • amean_filtered_running_field
      (nstitch)
      float64
      nan 14.75 14.7 ... 13.82 13.87 nan
      units :
      mm day-1
      long_name :
      LP object filtered running mean, mean rain rate (at end of running time).
      array([        nan, 14.74976528, 14.70394377, ..., 13.81580507,
             13.8683036 ,         nan])
    • min_inst_field
      (nstitch)
      float64
      nan 0.0 0.0 0.0 ... 0.0 0.0 0.0 nan
      units :
      mm h-1
      long_name :
      LP object min instantaneous rain rate (at end of running time).
      array([nan,  0.,  0., ...,  0.,  0., nan])
    • min_running_field
      (nstitch)
      float64
      nan 0.0 0.0 0.0 ... 2.668 2.668 nan
      units :
      mm day-1
      long_name :
      LP object running mean, min rain rate (at end of running time).
      array([       nan, 0.        , 0.        , ..., 2.66800189, 2.66800189,
                    nan])
    • min_filtered_running_field
      (nstitch)
      float64
      nan 12.0 12.0 ... 12.0 12.0 nan
      units :
      mm day-1
      long_name :
      LP object filtered running mean, min rain rate (at end of running time).
      array([        nan, 12.0000658 , 12.00043106, ..., 12.00000095,
             12.0003233 ,         nan])
    • max_inst_field
      (nstitch)
      float64
      nan 40.38 51.05 ... 21.7 31.63 nan
      units :
      mm h-1
      long_name :
      LP object max instantaneous rain rate (at end of running time).
      array([        nan, 40.38343048, 51.05173111, ..., 21.69963455,
             31.63000107,         nan])
    • max_running_field
      (nstitch)
      float64
      nan 196.9 192.4 ... 53.11 53.6 nan
      units :
      mm day-1
      long_name :
      LP object running mean, max rain rate (at end of running time).
      array([         nan, 196.87020874, 192.40090942, ...,  53.10988617,
              53.60186768,          nan])
    • max_filtered_running_field
      (nstitch)
      float64
      nan 18.93 18.76 ... 15.82 15.94 nan
      units :
      mm day-1
      long_name :
      LP object filtered running mean, max rain rate (at end of running time).
      array([        nan, 18.93068886, 18.75605774, ..., 15.82488728,
             15.94044781,         nan])
    • num_objects
      (nlpt)
      int32
      175 420 723 811 ... 252 201 230 180
      units :
      1
      description :
      Number of LP objects corresponding to each LPT system.
      array([ 175,  420,  723,  811,  759,  615,  703,  651,  562,  650,  598,
              178,  815,  658,  131,  203,  253,  191,  273,  360,  408,  197,
              172,  264,  189,  179,  369,  194,  304,  213,  228,  169,  685,
             1203,  430,  948,  527,  268, 1097, 1615,  268,  305,  208,  247,
              187,  199,  173,  258,  372, 1086, 1224,  534,  663,  189,  213,
              839,  420,  314,  231,  469,  334, 1303, 1446,  877,  735, 1147,
             1290,  721,  579,  905, 1048,  479,  337,  933, 1076,  507,  365,
              315,  458,  509,  129,  169,  403,  438,  726,  438,  842,  611,
              889,  187,  342,  247,  589,  444,  888,  321,  208,  267,  172,
              198,  380,  331,  413,  419,  252,  201,  230,  180], dtype=int32)
    • objid
      (nlpt, nobj)
      float64
      2.022e+13 2.022e+13 ... nan nan
      units :
      1
      description :
      Integer LP Object IDs corresponding to each LPT system.
      array([[2.02206010e+13, 2.02206010e+13, 2.02206010e+13, ...,
                         nan,            nan,            nan],
             [2.02206110e+13, 2.02206110e+13, 2.02206110e+13, ...,
                         nan,            nan,            nan],
             [2.02206242e+13, 2.02206242e+13, 2.02206242e+13, ...,
                         nan,            nan,            nan],
             ...,
             [2.02306222e+13, 2.02306222e+13, 2.02306222e+13, ...,
                         nan,            nan,            nan],
             [2.02306211e+13, 2.02306211e+13, 2.02306211e+13, ...,
                         nan,            nan,            nan],
             [2.02306231e+13, 2.02306231e+13, 2.02306231e+13, ...,
                         nan,            nan,            nan]])
    • nlpt
      PandasIndex
      PandasIndex(Index([  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
             ...
              98,  99, 100, 101, 102, 103, 104, 105, 106, 107],
            dtype='int32', name='nlpt', length=108))
    • nstitch
      PandasIndex
      PandasIndex(Index([    0,     1,     2,     3,     4,     5,     6,     7,     8,     9,
             ...
             51697, 51698, 51699, 51700, 51701, 51702, 51703, 51704, 51705, 51706],
            dtype='int32', name='nstitch', length=51707))
    • nobj
      PandasIndex
      PandasIndex(Index([   0,    1,    2,    3,    4,    5,    6,    7,    8,    9,
             ...
             1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614],
            dtype='int32', name='nobj', length=1615))
  • description :
    LPT Systems NetCDF file.

1.1. Time-longitude plot of LPT System centroids¶

In [ ]:
# Create a simple time-longitude plot covering the Indo-Pacific region
plt.figure()

# Markers with size according to by area
plt.scatter(lpt_systems['centroid_lon_stitched'],
         lpt_systems['timestamp_stitched'],
         s = 1e-5*lpt_systems['area_stitched'],
         c = 'none', edgecolors='k', zorder=200,
         linewidths=0.3)

# Draw a line for the centroid track
plt.plot(lpt_systems['centroid_lon_stitched'],
         lpt_systems['timestamp_stitched'], linewidth=1.3,
         color = 'darkorange', zorder=300)

# Set some plotting range limits
plt.gca().set_xlim([60, 240])
plt.gca().set_ylim([dt.datetime(2022,11,1,0,0,0),
                    dt.datetime(2023,5,1,0,0,0)])

# Some labeling
plt.gca().set_xlabel('Longitude')

# Add grid lines
plt.gca().grid(True, axis='both', linewidth=0.5,
               color='darkgrey', linestyle='--')
plt.title('Time-Longitude of LPT System Centroids')

# Save figure
fn_out = 'demo.time_lon_centroids.png'
print(f'--> {fn_out}')
plt.savefig(fn_out, dpi=100, bbox_inches='tight')
--> demo.time_lon_centroids.png

1.2. Plot a map with individual LPTs highlighted in different colors¶

The list of LPT System IDs is contained in the variable lptid. To link the track coordinates to the LPT IDs, the variable lptid_stitched has the same length as centroid_lon_stitched, and similar variables. Like the others, it has a NaN value inbetween the individual system tracks.

In [ ]:
# Plot a map of LPT system tracks, colored by the LPT system ID.
# This can also be done using "scatter" and setting colors to the lptid_stitched
# But here I want to illustrate extracting
# the coordinates for individual LPT systems.
fig = plt.figure()
CMAPNAME='tab10'
cmap = mpl.colormaps[CMAPNAME]


# Set up map background
ax = fig.add_subplot(1,1,1,projection=ccrs.Mercator(central_longitude=180))
ax.coastlines()
ax.set_extent([60, 240, -40, 40], crs=ccrs.PlateCarree())

# Loop over the list of LPT IDs
count = 0
for n, this_lptid in enumerate(lpt_systems['lptid'].data):
    # Choose a color for this LPT system.
    # The colormap 'tab10' has ten colors
    # but we need to feed it a value from 0.0 - 1.0
    # Therefore, get the ramainder on integer division by 10
    # and divide that by 10.0.
    this_color = cmap((n % 10)/10.0)

    # Extract the longitude and latitude for this LPT system
    # Need to be careful since these IDs are decimal values!!!
    #
    # For this case, using the == method seems to work
    # because lptid and lptid_stitched were saved the same
    # way to the NetCDF file.
    #
    # However, this will NOT work when matching these MJO IDs
    # with the values in the MJO list files, because those are
    # saved as decimals in text files and read in using Pandas.
    #
    # USING THE == METHOD WITH LPTID FROM THE MJO LIST FILES 
    # WILL RESULT IN MISSED MJO CASES!!!
    #
    # Recommendation: Always use the <0.00001 method for generality.
    #
    # The == method (not recommended)
    # X = lpt_systems['centroid_lon_stitched'].data[
    #         lpt_systems['lptid_stitched'] == this_lptid]
    # Y = lpt_systems['centroid_lat_stitched'].data[
    #         lpt_systems['lptid_stitched'] == this_lptid]
    #
    # The <0.00001 method (recommended)
    X = lpt_systems['centroid_lon_stitched'].data[
            np.abs(lpt_systems['lptid_stitched'] - this_lptid) < 0.00001]
    Y = lpt_systems['centroid_lat_stitched'].data[
            np.abs(lpt_systems['lptid_stitched'] - this_lptid) < 0.00001]

    if len(X) > 0:
        count += 1

    # Plot the track
    ax.plot(X, Y, color=this_color, transform=ccrs.PlateCarree())

print(count, ' systems.')

# Save figure
fn_out = 'demo.map_centroids.png'
print(f'--> {fn_out}')
plt.savefig(fn_out, dpi=100, bbox_inches='tight')
108  systems.
--> demo.map_centroids.png

2. Extract MJO LPT systems¶

The above plots were for all LPT systems, which are mostly NOT MJO systems.

To determine which ones are MJO LPTs, use the MJO list files. The MJO list files are simple text files that can be read using Pandas. The trick is to use read_fwf not read_csv..

In [ ]:
fn_mjo_list = ('data/imerg/g50_72h/thresh12/systems/'
               + 'mjo_lpt_list_imerg_2022060100_2023063023.txt')

mjo_list = pd.read_fwf(fn_mjo_list)
mjo_list
Out[ ]:
begin_tracking end_tracking lptid lptgroup duration mean_zonal_spd lpt_begin lpt_end eprop_begin_idx eprop_end_idx eprop_spd eprop_dur eprop_begin eprop_end eprop_lon_begin eprop_lon_end
0 2022060100 2023063023 2.70 2 425.0 7.71 2022063017 2022071810 0 415 7.66 415.0 2022063017 2022071800 63.4 169.9
1 2022060100 2023063023 4.10 4 777.0 0.34 2022071714 2022081823 0 520 1.35 520.0 2022071714 2022080806 66.9 103.0
2 2022060100 2023063023 6.10 6 202.0 3.84 2022072110 2022072920 14 200 3.98 186.0 2022072200 2022072918 270.1 291.2
3 2022060100 2023063023 21.80 21 1567.0 -0.45 2022092022 2022112505 972 1495 1.33 523.0 2022103110 2022112205 88.2 127.3
4 2022060100 2023063023 21.40 21 947.0 0.52 2022101618 2022112505 7 308 3.17 301.0 2022101701 2022102914 93.2 124.7
5 2022060100 2023063023 21.80 21 1567.0 -0.45 2022092022 2022112505 358 614 6.58 256.0 2022100520 2022101612 95.5 139.6
6 2022060100 2023063023 29.10 29 955.0 2.54 2022120201 2023011020 140 955 2.93 815.0 2022120721 2023011020 89.2 168.3
7 2022060100 2023063023 32.10 32 884.0 -0.35 2022121616 2023012212 349 758 -0.07 409.0 2023010203 2023011904 290.8 301.3
8 2022060100 2023063023 37.08 37 720.0 4.22 2023012019 2023021919 0 610 4.25 610.0 2023012019 2023021505 91.8 186.0
9 2022060100 2023063023 40.10 40 416.0 0.36 2023021322 2023030306 14 243 2.36 229.0 2023021502 2023022415 292.1 314.1
10 2022060100 2023063023 42.10 42 725.0 0.43 2023030502 2023040407 72 290 3.67 218.0 2023030802 2023031704 285.1 311.3
11 2022060100 2023063023 44.10 44 841.0 5.03 2023032106 2023042507 31 841 5.06 810.0 2023032213 2023042507 77.9 229.6
12 2022060100 2023063023 46.10 46 341.0 0.27 2023041500 2023042905 0 341 0.27 341.0 2023041500 2023042905 294.2 306.9
13 2022060100 2023063023 47.10 47 246.0 1.00 2023042009 2023043015 0 170 6.24 170.0 2023042009 2023042711 3.7 34.4
14 2022060100 2023063023 48.10 48 588.0 0.15 2023042510 2023051922 174 454 2.11 280.0 2023050216 2023051408 71.2 90.2
15 2022060100 2023063023 49.10 49 465.0 0.97 2023042812 2023051721 0 443 0.97 465.0 2023042812 2023051721 154.4 179.7
16 2022060100 2023063023 58.10 58 418.0 2.37 2023061313 2023063023 186 374 8.77 188.0 2023062107 2023062903 127.1 172.1

2.1. Time-Longitude plot highlighting the MJO LPTs¶

In [ ]:
# Create a simple time-longitude plot covering the Indo-Pacific region
plt.figure()

# Loop over the list of LPT IDs
count = 0
for n, this_lptid in enumerate(lpt_systems['lptid'].data):

    # Extract the longitude and latitude for this LPT system
    # Need to be careful since these IDs are decimal values!!!
    #
    # For this case, using the == method seems to work
    # because lptid and lptid_stitched were saved the same
    # way to the NetCDF file.
    #
    # However, this will NOT work when matching these MJO IDs
    # with the values in the MJO list files, because those are
    # saved as decimals in text files and read in using Pandas.
    #
    # USING THE == METHOD WITH LPTID FROM THE MJO LIST FILES 
    # WILL RESULT IN MISSED MJO CASES!!!
    #
    # Recommendation: Always use the <0.00001 method for generality.
    #
    # The == method (not recommended)
    # X = lpt_systems['centroid_lon_stitched'].data[
    #         lpt_systems['lptid_stitched'] == this_lptid]
    # Y = lpt_systems['timestamp_stitched'].data[
    #         lpt_systems['lptid_stitched'] == this_lptid]
    #
    # The <0.00001 method (recommended)
    X = lpt_systems['centroid_lon_stitched'].data[
            np.abs(lpt_systems['lptid_stitched'] - this_lptid) < 0.00001]
    Y = lpt_systems['timestamp_stitched'].data[
            np.abs(lpt_systems['lptid_stitched'] - this_lptid) < 0.00001]

    # Check whether it is an MJO LPT system.
    is_mjo = False
    if np.nanmin(np.abs(np.array(mjo_list['lptid'].values) - this_lptid)) < 0.00001:
        is_mjo = True
        count += 1
        print(f'MJO LPT System: {this_lptid}.')
        # Choose a color for this LPT system.
        # The colormap 'tab10' has ten colors
        # but we need to feed it a value from 0.0 - 1.0
        # Therefore, get the ramainder on integer division by 10
        # and divide that by 10.0.
        this_color = cmap((count % 10)/10.0)

    # Plot the track
    if is_mjo:
        plt.gca().plot(X, Y, color=this_color, linewidth=2, zorder=200)
    else:
        plt.gca().plot(X, Y, color='darkgrey', linewidth=1, zorder=100)


# Set some plotting range limits
plt.gca().set_xlim([60, 240])
plt.gca().set_ylim([dt.datetime(2022,11,1,0,0,0),
                    dt.datetime(2023,5,1,0,0,0)])

# Some labeling
plt.gca().set_xlabel('Longitude')

# Add grid lines
plt.gca().grid(True, axis='both', linewidth=0.5,
               color='darkgrey', linestyle='--')
plt.title('Time-Longitude of LPT System Centroids With MJO Highlighted')

# Save figure
fn_out = 'demo.time_lon_centroids.mjo_lpt.png'
print(f'--> {fn_out}')
plt.savefig(fn_out, dpi=100, bbox_inches='tight')
MJO LPT System: 2.7.
MJO LPT System: 4.1.
MJO LPT System: 6.1.
MJO LPT System: 21.4.
MJO LPT System: 21.8.
MJO LPT System: 29.1.
MJO LPT System: 32.1.
MJO LPT System: 37.08.
MJO LPT System: 40.1.
MJO LPT System: 42.1.
MJO LPT System: 44.1.
MJO LPT System: 46.1.
MJO LPT System: 47.1.
MJO LPT System: 48.1.
MJO LPT System: 49.1.
MJO LPT System: 58.1.
--> demo.time_lon_centroids.mjo_lpt.png
In [ ]: