class Config:

    # ── Paths ─────────────────────────────────────────────────────────────────
    # HPC paths; update for local development
    path_gribs = '/RHM-Lustre3.2/users/oper/opericon/ICON/OUTPUT/{}.global+N29/DOM02'
    
    grbs_msgs_mpz = {'a_ml': {70: ('u', 70), 144: ('v', 70), 218: ('t', 70)},
		     'a_pl': {66: ('t', 925), 63: ('t', 850)},
                     's': {6: ('2t',), 19: ('tp',)}}
    
    grbs_msgs_profiles = {
    's': [{'messages': [1], 'var': 'prmsl', 'levels': [0], 'smooth': True, 'name': 'prmsl'},
            {'messages': [6], 'var': '2t', 'levels': [2], 'smooth': True, 'name': '2t'},
             {'messages': [3], 'var': '10u', 'levels': [10], 'smooth': True, 'name': '10u'}, 
              {'messages': [4], 'var': '10v', 'levels': [10], 'smooth': True, 'name': '10v'}, 
              {'messages': [19], 'var': 'tp', 'levels': [0], 'smooth': True, 'name': 'tp'}, 
              {'messages': [19], 'var': 'tp', 'levels': [0], 'smooth': False, 'name': 'tp_raw'}],
    'a_pl': [{'messages': [66], 'var': 't', 'levels': [925], 'smooth': True, 'name': 't_925'},
             {'messages': [20], 'var': 'u', 'levels': [925], 'smooth': True, 'name': 'u_925'}, 
             {'messages': [43], 'var': 'v', 'levels': [925], 'smooth': True, 'name': 'v_925'}, 
             {'messages': [20], 'var': 'u', 'levels': [925], 'smooth': False, 'name': 'u_925_raw'}, # double opening
             {'messages': [43], 'var': 'v', 'levels': [925], 'smooth': False, 'name': 'v_925_raw'}], 
    'a_ml': [{'messages': list(range(74,65, -1)), 'var': 'u', 'levels': list(range(74,65, -1)), 'smooth': True, 'name': 'u'},
             {'messages': list(range(148, 139, -1)), 'var': 'v', 'levels': list(range(74,65, -1)), 'smooth': True, 'name': 'v'},
             {'messages': list(range(222, 213, -1)), 'var': 't', 'levels': list(range(74,65, -1)), 'smooth': True, 'name': 't'}]
}
    
    oper_dir = '/RHM-Lustre3.2/users/muza-art/dborisov/mprz/to_cray'
    #path_gribs = f'{oper_dir}/gribs_buf'
    constfields = f'{oper_dir}/CONSTS/ConstFields.npz'
    cities_csv = f'{oper_dir}/CONSTS/cities.csv'
    path_output = f'{oper_dir}/OUTPUT'

    # ── dimensions ──────────────────────────────────────────────────────────────────
    nlon      = 2000   # ICON-Ru6 columns (longitude direction)
    nlat      = 1000   # ICON-Ru6 rows    (latitude direction)
    nhours    = 49     # forecast hours: 0 – 48

    # ── Thresholds ────────────────────────────────────────────────────────────
    pr_min           =  0.1              # minimum precipitation (mm/h)                                           ## Checked
    par_adv_minus_cr = -2.0              # cold-advection threshold
    par_adv_plus_cr  =  5.0              # warm-advection threshold

    # ── Periodic forecast ───────────────────────────-──────────────────────────
    nperiods = 7
    prds_to_write = [2,3,4,5,6]

    # ── Period boundaries (0-based hour indices) by season ───────────────────────
    # Season 1 (winter):         Sep 21 – Mar 20
    # Season 2 (spring/autumn):  Mar 21 – Apr 20  and  Aug 21 – Sep 20
    # Season 3 (summer):         Apr 21 – Aug 20
    # Each entry: (init_nh, init_cpok, end_cpok) — all 0-based indices
    #   init_nh   — season-dependent Str/Vz 3-hour window start   (from cpok1/2/3 in fortran)
    #   init_cpok — fixed Pr accumulation window start
    #   end_cpok  — fixed period end (Pr window end)

    prd_bounds = {"winter": [(4,4,8), (10,9,14), (15,15,20), (22,21,27), (28,28,32), (34,33,38), (39,39,44)], 
                  "sprint_autumn":[(4,4,8), (10,9,14), (17,15,20), (22,21,27), (28,28,32), (34,33,38), (41,39,44)], 
                  "summer": [(3,4,8), (10,9,14), (18,15,20), (22,21,27), (27,28,32), (34,33,38), (42,39,44)]}
    
    # adv_bounds: (5, 3) list of (dt1_cpok, dt2_cpok, res_cpok) — 1-based, periods 3–7.
    #   dt1_cpok — first  advection reference hour: tadv[dt1] - tadv[dt1-3]
    #   dt2_cpok — second advection reference hour: tadv[dt2] - tadv[dt2-3]
    #   res_cpok — representative hour for the period (not city-shifted)

    # Fortran originals (all 7 periods, 1-based):
    # res_cpok = [ 8, 13, 19, 28, 32, 37, 43]
    # dt1_cpok = [ 4, 10, 16, 22, 28, 34, 40]
    # dt2_cpok = [ 7, 13, 19, 25, 31, 37, 43]

    adv_bounds = [(3, 6, 7), 
                  (9, 12, 12),
                  (15, 18, 18), 
                  (21, 24, 27), 
                  (27, 30, 31), 
                  (33, 36, 36), 
                  (39, 42, 42)]

    # ── Probablistic forecast ───────────────────────────────────
    dv_mod   = 1.0    # wind speed perturbation magnitude (m/s)                                                  ## Checked
    dstr_mod = 0.1    # stratification perturbation magnitude
    n_pert_vars = 9
    
    # pertrubation variants (9 variants)
    dv   = [0.0,    0.0,     0.0, 
            -dv_mod, -dv_mod, -dv_mod,
             dv_mod,  dv_mod,  dv_mod]

    dstr = [0.0,     -dstr_mod,  dstr_mod,
            0.0,     -dstr_mod,  dstr_mod,
            0.0,     -dstr_mod,  dstr_mod]
    
    # Periods anchors for probablistic forecast
    # Fortran uses fixed (non-seasonal) window anchors shifted by city UTC offset from Moscow.
    #    else if (np == 3) then
    #      nh1 = nhEvening - shift_time_mect
    #      nh2 = nh1 + N_nhEvening-1
    #    else if (np == 4) then
    #      nh1 = nhNight - shift_time_mect
    #      nh2 = nh1 + N_nhNight-1
    #    else if (np == 5) then
    #      nh1 = nhMorning - shift_time_mect
    #      nh2 = nh1 + N_nhMorning-1
    #    else if (np == 6) then
    #      nh1 = nhDay - shift_time_mect
    #      nh2 = nh1 + N_nhDay-1
    #    else if (np == 7) then
    #      nh1 = nhEvening2 - shift_time_mect
    #      nh2 = nh1 + N_nhEvening-1

    #    nhEvening  =  16
    #    nhNight    =  22
    #    nhMorning  =  29
    #    nhDay      =  33
    #    nhEvening2 =  40

    #    N_nhDay      = 7,
    #    N_nhEvening  = 6,         
    #    N_nhMorning  = 4,
    #    N_nhNight    = 7,
    
    # Python alternative (just lists)
    prob_srarts = [0, 9, 15, 21, 28, 32, 39]
    prob_lens   = [0, 7,  6,  7,  4,  7,  6]

