import os
from e3sm_diags.parameter.core_parameter import CoreParameter
from e3sm_diags.parameter.tc_analysis_parameter import TCAnalysisParameter
from e3sm_diags.run import runner


##param.test_data_path = '/Users/zhang40/Documents/ACME_simulations/E3SM_v1_H1_6hourly_TC/test'
#param.test_data_path = '/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis/1_2/1_2'
#param.test_name = '20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis' 
#param.test_data_path = '/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/extendedOutput.v3.LR.historical_0101/tc-analysis'
#param.test_name = 'extendedOutput.v3.LR.historical_0101' 
#param.short_test_name = 'v3.LR.historical_threshold_1.0'
#
#param.reference_data_path = '/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/tc-analysis'
#param.ref_name = 'obs'
#param.run_type = 'model_vs_obs'
#
simulations = ['tc-v1.HR.0026_0035','tc-v2.LR.2000_2014','tc-v3.HR.0006_0025','tc-v3.LR.2000_2014']
sim_names = ['theta.20180906.branch_noCNT.A_WCYCL1950S_CMIP6_HR.ne120_oRRS18v3_ICG','v2.LR.historical_0101','20240609.piCtl.ne120pg2_r025_RRSwISC6to18E3r5.chrysalis.test1','extendedOutput.v3.LR.historical_0101']

#simulations = ['tc-v2.LR.amip.2000_2014','tc-v3.LR.amip.2000_2014']
#sim_names = ['v2.LR.amip_0101','v3.LR.amip_0101']
#
#simulations = ['tc-v3.HR.F2010_nomassfluxadjust.0034_0035']
#sim_names = ['20240823.v3.F2010-TMSOROC05-Z0015.ne120pg2_r025_icos30.Nomassfluxadj.pm-cpu']
##
#simulations = ['tc-v3.HR.F2010_nomassfluxadjust.0034_720x1440']
#sim_names = ['20240823.v3.F2010-TMSOROC05-Z0015.ne120pg2_r025_icos30.Nomassfluxadj.pm-cpu']
##simulations = ['tc-v3.HR.F2010_baseline.0034_0035']
##sim_names = ['test.20240809.v3.F2010_newDustSeasalt.ne120pg2_r025_icos30.pm-cpu']
#simulations = ['tc-v3.HR.Nomassfluxadj_tuned.0038_0044']
#sim_names = ['20240827.v3.F2010-TMSOROC05-Z0015.ne120pg2_r025_icos30.Nomassfluxadj.n0256t120x1.kdreg2.hy']

data_path = '/global/homes/c/chengzhu/tests/tc_analysis/'

for idx, sim in enumerate(simulations):
    print(sim)
    param = CoreParameter()
    param.test_data_path = data_path+sim
    param.test_name = sim_names[idx]
    param.test_start_yr = sim.split('.')[-1][0:4]
    param.test_end_yr = sim.split('.')[-1][5:9]
    #param.test_start_yr = "0038"
    #param.test_end_yr = "0044"

    param.reference_data_path = '/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/tc-analysis'
    param.ref_start_yr = '1979'
    param.ref_end_yr = '2018'

    prefix = f'/global/cfs/cdirs/e3sm/www/chengzhu/tc_analysis_test/'
    param.results_dir = os.path.join(prefix, sim)
    runner.sets_to_run = ['tc_analysis']
    runner.run_diags([param])


    


