'''
Pre-defined model levels and a, b constants for the different weather models

**NOTE**: The fixed heights used here are from ECMWF's _geometric_ altitudes
(https://www.ecmwf.int/en/forecasts/documentation-and-support/137-model-levels),
where "geopotential altitude is calculated from a mathematical model that adjusts 
the altitude to include the variation of gravity with height, while geometric 
altitude is the standard direct vertical distance above mean sea level (MSL)."
- Wikipedia.org, https://en.wikipedia.org/wiki/International_Standard_Atmosphere
'''

LEVELS_137_HEIGHTS = [
    80301.65,
    74584.91,
    71918.79,
    69365.77,
    66906.53,
    64537.43,
    62254.39,
    60053.46,
    57930.78,
    55882.68,
    53905.62,
    51996.21,
    50159.36,
    48413.94,
    46756.98,
    45199.69,
    43738.55,
    42364.93,
    41071.2,
    39850.56,
    38696.94,
    37604.95,
    36569.72,
    35586.89,
    34652.52,
    33763.05,
    32915.27,
    32106.57,
    31330.96,
    30584.71,
    29866.09,
    29173.5,
    28505.47,
    27860.64,
    27237.73,
    26635.56,
    26053.04,
    25489.15,
    24942.93,
    24413.5,
    23900.02,
    23401.71,
    22917.85,
    22447.75,
    21990.82,
    21546.62,
    21114.77,
    20694.9,
    20286.66,
    19889.88,
    19503.09,
    19125.61,
    18756.34,
    18394.25,
    18038.35,
    17687.77,
    17341.62,
    16999.08,
    16659.55,
    16322.83,
    15988.88,
    15657.7,
    15329.24,
    15003.5,
    14680.44,
    14360.05,
    14042.3,
    13727.18,
    13414.65,
    13104.7,
    12797.3,
    12492.44,
    12190.1,
    11890.24,
    11592.86,
    11297.93,
    11005.69,
    10714.22,
    10422.64,
    10130.98,
    9839.26,
    9547.49,
    9255.7,
    8963.9,
    8672.11,
    8380.36,
    8088.67,
    7797.04,
    7505.51,
    7214.09,
    6922.8,
    6631.66,
    6340.68,
    6049.89,
    5759.3,
    5469.3,
    5180.98,
    4896.02,
    4615.92,
    4341.73,
    4074.41,
    3814.82,
    3563.69,
    3321.67,
    3089.25,
    2866.83,
    2654.69,
    2452.99,
    2261.8,
    2081.09,
    1910.76,
    1750.63,
    1600.44,
    1459.91,
    1328.7,
    1206.44,
    1092.73,
    987.15,
    889.29,
    798.72,
    715.02,
    637.76,
    566.54,
    500.95,
    440.61,
    385.16,
    334.24,
    287.52,
    244.69,
    205.44,
    169.51,
    136.62,
    106.54,
    79.04,
    53.92,
    30.96,
    10,
    0,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

A_ERAI = [
    0.0000000000e+000, 2.0000000000e+001, 3.8425338745e+001,
    6.3647796631e+001, 9.5636962891e+001, 1.3448330688e+002,
    1.8058435059e+002, 2.3477905273e+002, 2.9849584961e+002,
    3.7397192383e+002, 4.6461816406e+002, 5.7565112305e+002,
    7.1321801758e+002, 8.8366040039e+002, 1.0948347168e+003,
    1.3564746094e+003, 1.6806403809e+003, 2.0822739258e+003,
    2.5798886719e+003, 3.1964216309e+003, 3.9602915039e+003,
    4.9067070313e+003, 6.0180195313e+003, 7.3066328125e+003,
    8.7650546875e+003, 1.0376125000e+004, 1.2077445313e+004,
    1.3775324219e+004, 1.5379804688e+004, 1.6819472656e+004,
    1.8045183594e+004, 1.9027695313e+004, 1.9755109375e+004,
    2.0222203125e+004, 2.0429863281e+004, 2.0384480469e+004,
    2.0097402344e+004, 1.9584328125e+004, 1.8864750000e+004,
    1.7961359375e+004, 1.6899468750e+004, 1.5706449219e+004,
    1.4411125000e+004, 1.3043218750e+004, 1.1632757813e+004,
    1.0209500000e+004, 8.8023554688e+003, 7.4388046875e+003,
    6.1443164063e+003, 4.9417773438e+003, 3.8509133301e+003,
    2.8876965332e+003, 2.0637797852e+003, 1.3859125977e+003,
    8.5536181641e+002, 4.6733349609e+002, 2.1039389038e+002,
    6.5889236450e+001, 7.3677425385e+000, 0.0000000000e+000,
    0.0000000000e+000
]

B_ERAI = [
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    7.5823496445e-005, 4.6139489859e-004, 1.8151560798e-003,
    5.0811171532e-003, 1.1142909527e-002, 2.0677875727e-002,
    3.4121163189e-002, 5.1690407097e-002, 7.3533833027e-002,
    9.9674701691e-002, 1.3002252579e-001, 1.6438430548e-001,
    2.0247590542e-001, 2.4393314123e-001, 2.8832298517e-001,
    3.3515489101e-001, 3.8389211893e-001, 4.3396294117e-001,
    4.8477154970e-001, 5.3570991755e-001, 5.8616840839e-001,
    6.3554745913e-001, 6.8326860666e-001, 7.2878581285e-001,
    7.7159661055e-001, 8.1125342846e-001, 8.4737491608e-001,
    8.7965691090e-001, 9.0788388252e-001, 9.3194031715e-001,
    9.5182150602e-001, 9.6764522791e-001, 9.7966271639e-001,
    9.8827010393e-001, 9.9401944876e-001, 9.9763011932e-001,
    1.0000000000e+000
]

A_137_HRES = [
    0.00000000e+00, 2.00036502e+00, 3.10224104e+00, 4.66608381e+00,
    6.82797718e+00, 9.74696636e+00, 1.36054239e+01, 1.86089306e+01,
    2.49857178e+01, 3.29857101e+01, 4.28792419e+01, 5.49554634e+01,
    6.95205765e+01, 8.68958817e+01, 1.07415741e+02, 1.31425507e+02,
    1.59279404e+02, 1.91338562e+02, 2.27968948e+02, 2.69539581e+02,
    3.16420746e+02, 3.68982361e+02, 4.27592499e+02, 4.92616028e+02,
    5.64413452e+02, 6.43339905e+02, 7.29744141e+02, 8.23967834e+02,
    9.26344910e+02, 1.03720117e+03, 1.15685364e+03, 1.28561035e+03,
    1.42377014e+03, 1.57162292e+03, 1.72944897e+03, 1.89751929e+03,
    2.07609595e+03, 2.26543164e+03, 2.46577051e+03, 2.67734814e+03,
    2.90039136e+03, 3.13511938e+03, 3.38174365e+03, 3.64046826e+03,
    3.91149048e+03, 4.19493066e+03, 4.49081738e+03, 4.79914941e+03,
    5.11989502e+03, 5.45299072e+03, 5.79834473e+03, 6.15607422e+03,
    6.52694678e+03, 6.91187061e+03, 7.31186914e+03, 7.72741211e+03,
    8.15935400e+03, 8.60852539e+03, 9.07640039e+03, 9.56268262e+03,
    1.00659785e+04, 1.05846318e+04, 1.11166621e+04, 1.16600674e+04,
    1.22115479e+04, 1.27668730e+04, 1.33246689e+04, 1.38813311e+04,
    1.44321396e+04, 1.49756152e+04, 1.55082568e+04, 1.60261152e+04,
    1.65273223e+04, 1.70087891e+04, 1.74676133e+04, 1.79016211e+04,
    1.83084336e+04, 1.86857188e+04, 1.90312891e+04, 1.93435117e+04,
    1.96200430e+04, 1.98593906e+04, 2.00599316e+04, 2.02196641e+04,
    2.03378633e+04, 2.04123086e+04, 2.04420781e+04, 2.04257188e+04,
    2.03618164e+04, 2.02495117e+04, 2.00870859e+04, 1.98740254e+04,
    1.96085723e+04, 1.92902266e+04, 1.89174609e+04, 1.84897070e+04,
    1.80069258e+04, 1.74718398e+04, 1.68886875e+04, 1.62620469e+04,
    1.55966953e+04, 1.48984531e+04, 1.41733242e+04, 1.34277695e+04,
    1.26682578e+04, 1.19013398e+04, 1.11333047e+04, 1.03701758e+04,
    9.61751562e+03, 8.88045312e+03, 8.16337500e+03, 7.47034375e+03,
    6.80442188e+03, 6.16853125e+03, 5.56438281e+03, 4.99379688e+03,
    4.45737500e+03, 3.95596094e+03, 3.48923438e+03, 3.05726562e+03,
    2.65914062e+03, 2.29424219e+03, 1.96150000e+03, 1.65947656e+03,
    1.38754688e+03, 1.14325000e+03, 9.26507812e+02, 7.34992188e+02,
    5.68062500e+02, 4.24414062e+02, 3.02476562e+02, 2.02484375e+02,
    1.22101562e+02, 6.27812500e+01, 2.28359375e+01, 3.75781298e+00,
    0.00000000e+00, 0.00000000e+00,
]

B_137_HRES = [
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 3.81999996e-08, 6.76070022e-06,
    2.43480008e-05, 5.89219999e-05, 1.11914298e-04, 1.98577400e-04,
    3.40379687e-04, 5.61555324e-04, 8.89697927e-04, 1.35280553e-03,
    1.99183798e-03, 2.85712420e-03, 3.97095364e-03, 5.37781464e-03,
    7.13337678e-03, 9.26146004e-03, 1.18060224e-02, 1.48156285e-02,
    1.83184519e-02, 2.23548450e-02, 2.69635208e-02, 3.21760960e-02,
    3.80263999e-02, 4.45479602e-02, 5.17730154e-02, 5.97284138e-02,
    6.84482530e-02, 7.79583082e-02, 8.82857367e-02, 9.94616672e-02,
    1.11504652e-01, 1.24448128e-01, 1.38312891e-01, 1.53125033e-01,
    1.68910414e-01, 1.85689449e-01, 2.03491211e-01, 2.22332865e-01,
    2.42244005e-01, 2.63241887e-01, 2.85354018e-01, 3.08598459e-01,
    3.32939088e-01, 3.58254194e-01, 3.84363323e-01, 4.11124766e-01,
    4.38391209e-01, 4.66003299e-01, 4.93800312e-01, 5.21619201e-01,
    5.49301147e-01, 5.76692164e-01, 6.03648067e-01, 6.30035818e-01,
    6.55735970e-01, 6.80643022e-01, 7.04668999e-01, 7.27738738e-01,
    7.49796569e-01, 7.70797551e-01, 7.90716767e-01, 8.09536040e-01,
    8.27256083e-01, 8.43881130e-01, 8.59431803e-01, 8.73929262e-01,
    8.87407541e-01, 8.99900496e-01, 9.11448181e-01, 9.22095656e-01,
    9.31880772e-01, 9.40859556e-01, 9.49064434e-01, 9.56549525e-01,
    9.63351727e-01, 9.69513416e-01, 9.75078404e-01, 9.80071604e-01,
    9.84541893e-01, 9.88499522e-01, 9.91984010e-01, 9.95002508e-01,
    9.97630119e-01, 1.00000000e+00,
]

LEVELS_91_HEIGHTS = [
    80302.61,
    73584.94,
    69438.73,
    65514.87,
    61797.72,
    58276.46,
    54940.11,
    51777.87,
    48814.03,
    46090.25,
    43628.96,
    41403.86,
    39383.7,
    37542.4,
    35858.04,
    34312.09,
    32888.77,
    31573.56,
    30345.38,
    29194.77,
    28114.89,
    27099.67,
    26143.71,
    25242.19,
    24390.8,
    23585.66,
    22823.27,
    22100.5,
    21414.49,
    20762.65,
    20142.64,
    19552.08,
    18988,
    18449.43,
    17934.94,
    17441.91,
    16966.91,
    16506.76,
    16058.63,
    15619.91,
    15188.19,
    14761.17,
    14337.21,
    13915.75,
    13496.8,
    13080.33,
    12666.32,
    12254.76,
    11845.64,
    11438.95,
    11034.66,
    10630.79,
    10224.21,
    9815.19,
    9403.75,
    8989.9,
    8573.66,
    8155.04,
    7734.06,
    7310.73,
    6885.19,
    6457.87,
    6031.31,
    5609.68,
    5196.66,
    4795.53,
    4409.09,
    4038.88,
    3685.3,
    3348.45,
    3028.28,
    2725.01,
    2438.89,
    2169.89,
    1917.84,
    1682.8,
    1464.87,
    1263.88,
    1079.52,
    911.61,
    760.08,
    624.59,
    504.57,
    399.52,
    309.04,
    232.5,
    167.39,
    112.26,
    67.88,
    34.22,
    10,
    0,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

A_91_HRES = [
    0.000000, 2.000040, 3.980832, 7.387186, 12.908319, 21.413612, 33.952858,
    51.746601, 76.167656, 108.715561, 150.986023, 204.637451, 271.356506,
    352.824493, 450.685791, 566.519226, 701.813354, 857.945801, 1036.166504,
    1237.585449, 1463.163940, 1713.709595, 1989.874390, 2292.155518, 2620.898438,
    2976.302246, 3358.425781, 3767.196045, 4202.416504, 4663.776367, 5150.859863,
    5663.156250, 6199.839355, 6759.727051, 7341.469727, 7942.926270, 8564.624023,
    9208.305664, 9873.560547, 10558.881836, 11262.484375, 11982.662109, 12713.897461,
    13453.225586, 14192.009766, 14922.685547, 15638.053711, 16329.560547, 16990.623047,
    17613.281250, 18191.029297, 18716.968750, 19184.544922, 19587.513672, 19919.796875,
    20175.394531, 20348.916016, 20434.158203, 20426.218750, 20319.011719, 20107.031250,
    19785.357422, 19348.775391, 18798.822266, 18141.296875, 17385.595703, 16544.585938,
    15633.566406, 14665.645508, 13653.219727, 12608.383789, 11543.166992, 10471.310547,
    9405.222656, 8356.252930, 7335.164551, 6353.920898, 5422.802734, 4550.215820, 3743.464355,
    3010.146973, 2356.202637, 1784.854614, 1297.656128, 895.193542, 576.314148, 336.772369,
    162.043427, 54.208336, 6.575628, 0.003160, 0.000000
]

B_91_HRES = [
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000014,
    0.000055, 0.000131, 0.000279, 0.000548, 0.001000, 0.001701, 0.002765, 0.004267, 0.006322,
    0.009035, 0.012508, 0.016860, 0.022189, 0.028610, 0.036227, 0.045146, 0.055474, 0.067316,
    0.080777, 0.095964, 0.112979, 0.131935, 0.152934, 0.176091, 0.201520, 0.229315, 0.259554,
    0.291993, 0.326329, 0.362203, 0.399205, 0.436906, 0.475016, 0.513280, 0.551458, 0.589317,
    0.626559, 0.662934, 0.698224, 0.732224, 0.764679, 0.795385, 0.824185, 0.850950, 0.875518,
    0.897767, 0.917651, 0.935157, 0.950274, 0.963007, 0.973466, 0.982238, 0.989153, 0.994204,
    0.997630, 1.000000
]

A_137_ERA5 = [
    0.000000, 2.000365, 3.102241, 4.666084, 6.827977,
    9.746966, 13.605424, 18.608931, 24.985718, 32.985710,
    42.879242, 54.955463, 69.520576, 86.895882, 107.415741,
    131.425507, 159.279404, 191.338562, 227.968948, 269.539581,
    316.420746, 368.982361, 427.592499, 492.616028, 564.413452,
    643.339905, 729.744141, 823.967834, 926.344910, 1037.201172,
    1156.853638, 1285.610352, 1423.770142, 1571.622925, 1729.448975,
    1897.519287, 2076.095947, 2265.431641, 2465.770508, 2677.348145,
    2900.391357, 3135.119385, 3381.743652, 3640.468262, 3911.490479,
    4194.930664, 4490.817383, 4799.149414, 5119.895020, 5452.990723,
    5798.344727, 6156.074219, 6526.946777, 6911.870605, 7311.869141,
    7727.412109, 8159.354004, 8608.525391, 9076.400391, 9562.682617,
    10065.978516, 10584.631836, 11116.662109, 11660.067383, 12211.547852,
    12766.873047, 13324.668945, 13881.331055, 14432.139648, 14975.615234,
    15508.256836, 16026.115234, 16527.322266, 17008.789063, 17467.613281,
    17901.621094, 18308.433594, 18685.718750, 19031.289063, 19343.511719,
    19620.042969, 19859.390625, 20059.931641, 20219.664063, 20337.863281,
    20412.308594, 20442.078125, 20425.718750, 20361.816406, 20249.511719,
    20087.085938, 19874.025391, 19608.572266, 19290.226563, 18917.460938,
    18489.707031, 18006.925781, 17471.839844, 16888.687500, 16262.046875,
    15596.695313, 14898.453125, 14173.324219, 13427.769531, 12668.257813,
    11901.339844, 11133.304688, 10370.175781, 9617.515625, 8880.453125,
    8163.375000, 7470.343750, 6804.421875, 6168.531250, 5564.382813,
    4993.796875, 4457.375000, 3955.960938, 3489.234375, 3057.265625,
    2659.140625, 2294.242188, 1961.500000, 1659.476563, 1387.546875,
    1143.250000, 926.507813, 734.992188, 568.062500, 424.414063,
    302.476563, 202.484375, 122.101563, 62.781250, 22.835938,
    3.757813, 0.000000, 0.000000
]

B_137_ERA5 = [
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000007,
    0.000024, 0.000059, 0.000112, 0.000199, 0.000340, 0.000562, 0.000890,
    0.001353, 0.001992, 0.002857, 0.003971, 0.005378, 0.007133, 0.009261,
    0.011806, 0.014816, 0.018318, 0.022355, 0.026964, 0.032176, 0.038026,
    0.044548, 0.051773, 0.059728, 0.068448, 0.077958, 0.088286, 0.099462,
    0.111505, 0.124448, 0.138313, 0.153125, 0.168910, 0.185689, 0.203491,
    0.222333, 0.242244, 0.263242, 0.285354, 0.308598, 0.332939, 0.358254,
    0.384363, 0.411125, 0.438391, 0.466003, 0.493800, 0.521619, 0.549301,
    0.576692, 0.603648, 0.630036, 0.655736, 0.680643, 0.704669, 0.727739,
    0.749797, 0.770798, 0.790717, 0.809536, 0.827256, 0.843881, 0.859432,
    0.873929, 0.887408, 0.899900, 0.911448, 0.922096, 0.931881, 0.940860,
    0.949064, 0.956550, 0.963352, 0.969513, 0.975078, 0.980072, 0.984542,
    0.988500, 0.991984, 0.995003, 0.997630, 1.000000
]

# HRES PRESSURE LEVELS:
# 1000, 950, 925, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 7, 5, 3, 2, 1 hPa
LEVELS_25_HEIGHTS = [
    48413.94,
    43738.55,
    39850.56,
    36569.72,
    33763.05,
    31330.96,
    26635.56,
    24413.5,
    20694.9,
    18394.25,
    16322.83,
    13727.18,
    11890.24,
    10422.64,
    9255.7,
    7214.09,
    5469.3,
    4074.41,
    3089.25,
    1910.76,
    1459.91,
    987.15,
    798.72,
    566.54,
    106.54,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

'''
Pre-defined model levels and a, b constants for the different weather models

**NOTE**: The fixed heights used here are from ECMWF's _geometric_ altitudes
(https://www.ecmwf.int/en/forecasts/documentation-and-support/137-model-levels),
where "geopotential altitude is calculated from a mathematical model that adjusts 
the altitude to include the variation of gravity with height, while geometric 
altitude is the standard direct vertical distance above mean sea level (MSL)."
- Wikipedia.org, https://en.wikipedia.org/wiki/International_Standard_Atmosphere
'''

LEVELS_137_HEIGHTS = [
    80301.65,
    74584.91,
    71918.79,
    69365.77,
    66906.53,
    64537.43,
    62254.39,
    60053.46,
    57930.78,
    55882.68,
    53905.62,
    51996.21,
    50159.36,
    48413.94,
    46756.98,
    45199.69,
    43738.55,
    42364.93,
    41071.2,
    39850.56,
    38696.94,
    37604.95,
    36569.72,
    35586.89,
    34652.52,
    33763.05,
    32915.27,
    32106.57,
    31330.96,
    30584.71,
    29866.09,
    29173.5,
    28505.47,
    27860.64,
    27237.73,
    26635.56,
    26053.04,
    25489.15,
    24942.93,
    24413.5,
    23900.02,
    23401.71,
    22917.85,
    22447.75,
    21990.82,
    21546.62,
    21114.77,
    20694.9,
    20286.66,
    19889.88,
    19503.09,
    19125.61,
    18756.34,
    18394.25,
    18038.35,
    17687.77,
    17341.62,
    16999.08,
    16659.55,
    16322.83,
    15988.88,
    15657.7,
    15329.24,
    15003.5,
    14680.44,
    14360.05,
    14042.3,
    13727.18,
    13414.65,
    13104.7,
    12797.3,
    12492.44,
    12190.1,
    11890.24,
    11592.86,
    11297.93,
    11005.69,
    10714.22,
    10422.64,
    10130.98,
    9839.26,
    9547.49,
    9255.7,
    8963.9,
    8672.11,
    8380.36,
    8088.67,
    7797.04,
    7505.51,
    7214.09,
    6922.8,
    6631.66,
    6340.68,
    6049.89,
    5759.3,
    5469.3,
    5180.98,
    4896.02,
    4615.92,
    4341.73,
    4074.41,
    3814.82,
    3563.69,
    3321.67,
    3089.25,
    2866.83,
    2654.69,
    2452.99,
    2261.8,
    2081.09,
    1910.76,
    1750.63,
    1600.44,
    1459.91,
    1328.7,
    1206.44,
    1092.73,
    987.15,
    889.29,
    798.72,
    715.02,
    637.76,
    566.54,
    500.95,
    440.61,
    385.16,
    334.24,
    287.52,
    244.69,
    205.44,
    169.51,
    136.62,
    106.54,
    79.04,
    53.92,
    30.96,
    10,
    0,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

A_ERAI = [
    0.0000000000e+000, 2.0000000000e+001, 3.8425338745e+001,
    6.3647796631e+001, 9.5636962891e+001, 1.3448330688e+002,
    1.8058435059e+002, 2.3477905273e+002, 2.9849584961e+002,
    3.7397192383e+002, 4.6461816406e+002, 5.7565112305e+002,
    7.1321801758e+002, 8.8366040039e+002, 1.0948347168e+003,
    1.3564746094e+003, 1.6806403809e+003, 2.0822739258e+003,
    2.5798886719e+003, 3.1964216309e+003, 3.9602915039e+003,
    4.9067070313e+003, 6.0180195313e+003, 7.3066328125e+003,
    8.7650546875e+003, 1.0376125000e+004, 1.2077445313e+004,
    1.3775324219e+004, 1.5379804688e+004, 1.6819472656e+004,
    1.8045183594e+004, 1.9027695313e+004, 1.9755109375e+004,
    2.0222203125e+004, 2.0429863281e+004, 2.0384480469e+004,
    2.0097402344e+004, 1.9584328125e+004, 1.8864750000e+004,
    1.7961359375e+004, 1.6899468750e+004, 1.5706449219e+004,
    1.4411125000e+004, 1.3043218750e+004, 1.1632757813e+004,
    1.0209500000e+004, 8.8023554688e+003, 7.4388046875e+003,
    6.1443164063e+003, 4.9417773438e+003, 3.8509133301e+003,
    2.8876965332e+003, 2.0637797852e+003, 1.3859125977e+003,
    8.5536181641e+002, 4.6733349609e+002, 2.1039389038e+002,
    6.5889236450e+001, 7.3677425385e+000, 0.0000000000e+000,
    0.0000000000e+000
]

B_ERAI = [
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    0.0000000000e+000, 0.0000000000e+000, 0.0000000000e+000,
    7.5823496445e-005, 4.6139489859e-004, 1.8151560798e-003,
    5.0811171532e-003, 1.1142909527e-002, 2.0677875727e-002,
    3.4121163189e-002, 5.1690407097e-002, 7.3533833027e-002,
    9.9674701691e-002, 1.3002252579e-001, 1.6438430548e-001,
    2.0247590542e-001, 2.4393314123e-001, 2.8832298517e-001,
    3.3515489101e-001, 3.8389211893e-001, 4.3396294117e-001,
    4.8477154970e-001, 5.3570991755e-001, 5.8616840839e-001,
    6.3554745913e-001, 6.8326860666e-001, 7.2878581285e-001,
    7.7159661055e-001, 8.1125342846e-001, 8.4737491608e-001,
    8.7965691090e-001, 9.0788388252e-001, 9.3194031715e-001,
    9.5182150602e-001, 9.6764522791e-001, 9.7966271639e-001,
    9.8827010393e-001, 9.9401944876e-001, 9.9763011932e-001,
    1.0000000000e+000
]

A_137_HRES = [
    0.00000000e+00, 2.00036502e+00, 3.10224104e+00, 4.66608381e+00,
    6.82797718e+00, 9.74696636e+00, 1.36054239e+01, 1.86089306e+01,
    2.49857178e+01, 3.29857101e+01, 4.28792419e+01, 5.49554634e+01,
    6.95205765e+01, 8.68958817e+01, 1.07415741e+02, 1.31425507e+02,
    1.59279404e+02, 1.91338562e+02, 2.27968948e+02, 2.69539581e+02,
    3.16420746e+02, 3.68982361e+02, 4.27592499e+02, 4.92616028e+02,
    5.64413452e+02, 6.43339905e+02, 7.29744141e+02, 8.23967834e+02,
    9.26344910e+02, 1.03720117e+03, 1.15685364e+03, 1.28561035e+03,
    1.42377014e+03, 1.57162292e+03, 1.72944897e+03, 1.89751929e+03,
    2.07609595e+03, 2.26543164e+03, 2.46577051e+03, 2.67734814e+03,
    2.90039136e+03, 3.13511938e+03, 3.38174365e+03, 3.64046826e+03,
    3.91149048e+03, 4.19493066e+03, 4.49081738e+03, 4.79914941e+03,
    5.11989502e+03, 5.45299072e+03, 5.79834473e+03, 6.15607422e+03,
    6.52694678e+03, 6.91187061e+03, 7.31186914e+03, 7.72741211e+03,
    8.15935400e+03, 8.60852539e+03, 9.07640039e+03, 9.56268262e+03,
    1.00659785e+04, 1.05846318e+04, 1.11166621e+04, 1.16600674e+04,
    1.22115479e+04, 1.27668730e+04, 1.33246689e+04, 1.38813311e+04,
    1.44321396e+04, 1.49756152e+04, 1.55082568e+04, 1.60261152e+04,
    1.65273223e+04, 1.70087891e+04, 1.74676133e+04, 1.79016211e+04,
    1.83084336e+04, 1.86857188e+04, 1.90312891e+04, 1.93435117e+04,
    1.96200430e+04, 1.98593906e+04, 2.00599316e+04, 2.02196641e+04,
    2.03378633e+04, 2.04123086e+04, 2.04420781e+04, 2.04257188e+04,
    2.03618164e+04, 2.02495117e+04, 2.00870859e+04, 1.98740254e+04,
    1.96085723e+04, 1.92902266e+04, 1.89174609e+04, 1.84897070e+04,
    1.80069258e+04, 1.74718398e+04, 1.68886875e+04, 1.62620469e+04,
    1.55966953e+04, 1.48984531e+04, 1.41733242e+04, 1.34277695e+04,
    1.26682578e+04, 1.19013398e+04, 1.11333047e+04, 1.03701758e+04,
    9.61751562e+03, 8.88045312e+03, 8.16337500e+03, 7.47034375e+03,
    6.80442188e+03, 6.16853125e+03, 5.56438281e+03, 4.99379688e+03,
    4.45737500e+03, 3.95596094e+03, 3.48923438e+03, 3.05726562e+03,
    2.65914062e+03, 2.29424219e+03, 1.96150000e+03, 1.65947656e+03,
    1.38754688e+03, 1.14325000e+03, 9.26507812e+02, 7.34992188e+02,
    5.68062500e+02, 4.24414062e+02, 3.02476562e+02, 2.02484375e+02,
    1.22101562e+02, 6.27812500e+01, 2.28359375e+01, 3.75781298e+00,
    0.00000000e+00, 0.00000000e+00,
]

B_137_HRES = [
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
    0.00000000e+00, 0.00000000e+00, 3.81999996e-08, 6.76070022e-06,
    2.43480008e-05, 5.89219999e-05, 1.11914298e-04, 1.98577400e-04,
    3.40379687e-04, 5.61555324e-04, 8.89697927e-04, 1.35280553e-03,
    1.99183798e-03, 2.85712420e-03, 3.97095364e-03, 5.37781464e-03,
    7.13337678e-03, 9.26146004e-03, 1.18060224e-02, 1.48156285e-02,
    1.83184519e-02, 2.23548450e-02, 2.69635208e-02, 3.21760960e-02,
    3.80263999e-02, 4.45479602e-02, 5.17730154e-02, 5.97284138e-02,
    6.84482530e-02, 7.79583082e-02, 8.82857367e-02, 9.94616672e-02,
    1.11504652e-01, 1.24448128e-01, 1.38312891e-01, 1.53125033e-01,
    1.68910414e-01, 1.85689449e-01, 2.03491211e-01, 2.22332865e-01,
    2.42244005e-01, 2.63241887e-01, 2.85354018e-01, 3.08598459e-01,
    3.32939088e-01, 3.58254194e-01, 3.84363323e-01, 4.11124766e-01,
    4.38391209e-01, 4.66003299e-01, 4.93800312e-01, 5.21619201e-01,
    5.49301147e-01, 5.76692164e-01, 6.03648067e-01, 6.30035818e-01,
    6.55735970e-01, 6.80643022e-01, 7.04668999e-01, 7.27738738e-01,
    7.49796569e-01, 7.70797551e-01, 7.90716767e-01, 8.09536040e-01,
    8.27256083e-01, 8.43881130e-01, 8.59431803e-01, 8.73929262e-01,
    8.87407541e-01, 8.99900496e-01, 9.11448181e-01, 9.22095656e-01,
    9.31880772e-01, 9.40859556e-01, 9.49064434e-01, 9.56549525e-01,
    9.63351727e-01, 9.69513416e-01, 9.75078404e-01, 9.80071604e-01,
    9.84541893e-01, 9.88499522e-01, 9.91984010e-01, 9.95002508e-01,
    9.97630119e-01, 1.00000000e+00,
]

LEVELS_91_HEIGHTS = [
    80302.61,
    73584.94,
    69438.73,
    65514.87,
    61797.72,
    58276.46,
    54940.11,
    51777.87,
    48814.03,
    46090.25,
    43628.96,
    41403.86,
    39383.7,
    37542.4,
    35858.04,
    34312.09,
    32888.77,
    31573.56,
    30345.38,
    29194.77,
    28114.89,
    27099.67,
    26143.71,
    25242.19,
    24390.8,
    23585.66,
    22823.27,
    22100.5,
    21414.49,
    20762.65,
    20142.64,
    19552.08,
    18988,
    18449.43,
    17934.94,
    17441.91,
    16966.91,
    16506.76,
    16058.63,
    15619.91,
    15188.19,
    14761.17,
    14337.21,
    13915.75,
    13496.8,
    13080.33,
    12666.32,
    12254.76,
    11845.64,
    11438.95,
    11034.66,
    10630.79,
    10224.21,
    9815.19,
    9403.75,
    8989.9,
    8573.66,
    8155.04,
    7734.06,
    7310.73,
    6885.19,
    6457.87,
    6031.31,
    5609.68,
    5196.66,
    4795.53,
    4409.09,
    4038.88,
    3685.3,
    3348.45,
    3028.28,
    2725.01,
    2438.89,
    2169.89,
    1917.84,
    1682.8,
    1464.87,
    1263.88,
    1079.52,
    911.61,
    760.08,
    624.59,
    504.57,
    399.52,
    309.04,
    232.5,
    167.39,
    112.26,
    67.88,
    34.22,
    10,
    0,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

A_91_HRES = [
    0.000000, 2.000040, 3.980832, 7.387186, 12.908319, 21.413612, 33.952858,
    51.746601, 76.167656, 108.715561, 150.986023, 204.637451, 271.356506,
    352.824493, 450.685791, 566.519226, 701.813354, 857.945801, 1036.166504,
    1237.585449, 1463.163940, 1713.709595, 1989.874390, 2292.155518, 2620.898438,
    2976.302246, 3358.425781, 3767.196045, 4202.416504, 4663.776367, 5150.859863,
    5663.156250, 6199.839355, 6759.727051, 7341.469727, 7942.926270, 8564.624023,
    9208.305664, 9873.560547, 10558.881836, 11262.484375, 11982.662109, 12713.897461,
    13453.225586, 14192.009766, 14922.685547, 15638.053711, 16329.560547, 16990.623047,
    17613.281250, 18191.029297, 18716.968750, 19184.544922, 19587.513672, 19919.796875,
    20175.394531, 20348.916016, 20434.158203, 20426.218750, 20319.011719, 20107.031250,
    19785.357422, 19348.775391, 18798.822266, 18141.296875, 17385.595703, 16544.585938,
    15633.566406, 14665.645508, 13653.219727, 12608.383789, 11543.166992, 10471.310547,
    9405.222656, 8356.252930, 7335.164551, 6353.920898, 5422.802734, 4550.215820, 3743.464355,
    3010.146973, 2356.202637, 1784.854614, 1297.656128, 895.193542, 576.314148, 336.772369,
    162.043427, 54.208336, 6.575628, 0.003160, 0.000000
]

B_91_HRES = [
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000014,
    0.000055, 0.000131, 0.000279, 0.000548, 0.001000, 0.001701, 0.002765, 0.004267, 0.006322,
    0.009035, 0.012508, 0.016860, 0.022189, 0.028610, 0.036227, 0.045146, 0.055474, 0.067316,
    0.080777, 0.095964, 0.112979, 0.131935, 0.152934, 0.176091, 0.201520, 0.229315, 0.259554,
    0.291993, 0.326329, 0.362203, 0.399205, 0.436906, 0.475016, 0.513280, 0.551458, 0.589317,
    0.626559, 0.662934, 0.698224, 0.732224, 0.764679, 0.795385, 0.824185, 0.850950, 0.875518,
    0.897767, 0.917651, 0.935157, 0.950274, 0.963007, 0.973466, 0.982238, 0.989153, 0.994204,
    0.997630, 1.000000
]

A_137_ERA5 = [
    0.000000, 2.000365, 3.102241, 4.666084, 6.827977,
    9.746966, 13.605424, 18.608931, 24.985718, 32.985710,
    42.879242, 54.955463, 69.520576, 86.895882, 107.415741,
    131.425507, 159.279404, 191.338562, 227.968948, 269.539581,
    316.420746, 368.982361, 427.592499, 492.616028, 564.413452,
    643.339905, 729.744141, 823.967834, 926.344910, 1037.201172,
    1156.853638, 1285.610352, 1423.770142, 1571.622925, 1729.448975,
    1897.519287, 2076.095947, 2265.431641, 2465.770508, 2677.348145,
    2900.391357, 3135.119385, 3381.743652, 3640.468262, 3911.490479,
    4194.930664, 4490.817383, 4799.149414, 5119.895020, 5452.990723,
    5798.344727, 6156.074219, 6526.946777, 6911.870605, 7311.869141,
    7727.412109, 8159.354004, 8608.525391, 9076.400391, 9562.682617,
    10065.978516, 10584.631836, 11116.662109, 11660.067383, 12211.547852,
    12766.873047, 13324.668945, 13881.331055, 14432.139648, 14975.615234,
    15508.256836, 16026.115234, 16527.322266, 17008.789063, 17467.613281,
    17901.621094, 18308.433594, 18685.718750, 19031.289063, 19343.511719,
    19620.042969, 19859.390625, 20059.931641, 20219.664063, 20337.863281,
    20412.308594, 20442.078125, 20425.718750, 20361.816406, 20249.511719,
    20087.085938, 19874.025391, 19608.572266, 19290.226563, 18917.460938,
    18489.707031, 18006.925781, 17471.839844, 16888.687500, 16262.046875,
    15596.695313, 14898.453125, 14173.324219, 13427.769531, 12668.257813,
    11901.339844, 11133.304688, 10370.175781, 9617.515625, 8880.453125,
    8163.375000, 7470.343750, 6804.421875, 6168.531250, 5564.382813,
    4993.796875, 4457.375000, 3955.960938, 3489.234375, 3057.265625,
    2659.140625, 2294.242188, 1961.500000, 1659.476563, 1387.546875,
    1143.250000, 926.507813, 734.992188, 568.062500, 424.414063,
    302.476563, 202.484375, 122.101563, 62.781250, 22.835938,
    3.757813, 0.000000, 0.000000
]

B_137_ERA5 = [
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000007,
    0.000024, 0.000059, 0.000112, 0.000199, 0.000340, 0.000562, 0.000890,
    0.001353, 0.001992, 0.002857, 0.003971, 0.005378, 0.007133, 0.009261,
    0.011806, 0.014816, 0.018318, 0.022355, 0.026964, 0.032176, 0.038026,
    0.044548, 0.051773, 0.059728, 0.068448, 0.077958, 0.088286, 0.099462,
    0.111505, 0.124448, 0.138313, 0.153125, 0.168910, 0.185689, 0.203491,
    0.222333, 0.242244, 0.263242, 0.285354, 0.308598, 0.332939, 0.358254,
    0.384363, 0.411125, 0.438391, 0.466003, 0.493800, 0.521619, 0.549301,
    0.576692, 0.603648, 0.630036, 0.655736, 0.680643, 0.704669, 0.727739,
    0.749797, 0.770798, 0.790717, 0.809536, 0.827256, 0.843881, 0.859432,
    0.873929, 0.887408, 0.899900, 0.911448, 0.922096, 0.931881, 0.940860,
    0.949064, 0.956550, 0.963352, 0.969513, 0.975078, 0.980072, 0.984542,
    0.988500, 0.991984, 0.995003, 0.997630, 1.000000
]

# HRES PRESSURE LEVELS:
# 1000, 950, 925, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 7, 5, 3, 2, 1 hPa
LEVELS_25_HEIGHTS = [
    48413.94,
    43738.55,
    39850.56,
    36569.72,
    33763.05,
    31330.96,
    26635.56,
    24413.5,
    20694.9,
    18394.25,
    16322.83,
    13727.18,
    11890.24,
    10422.64,
    9255.7,
    7214.09,
    5469.3,
    4074.41,
    3089.25,
    1910.76,
    1459.91,
    987.15,
    798.72,
    566.54,
    106.54,
    -10,
    -20,
    -50,
    -100,
    -200,
    -300,
    -500,
]

Pre-defined model levels and a, b constants for the different weather models  **NOTE**: The fixed heights used here are from ECMWF's _geometric_ altitudes (https://www.ecmwf.int/en/forecasts/documentation-and-support/137-model-levels), where "geopotential altitude is calculated from a mathematical model that adjusts  the altitude to include the variation of gravity with height, while geometric  altitude is the standard direct vertical distance above mean sea level (MSL)." - Wikipedia.org, https://en.wikipedia.org/wiki/International_Standard_Atmosphere # HRES PRESSURE LEVELS: # 1000, 950, 925, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 7, 5, 3, 2, 1 hPa