diff --git a/arm_diags/.DS_Store b/arm_diags/.DS_Store index 96c4b32..660471e 100644 Binary files a/arm_diags/.DS_Store and b/arm_diags/.DS_Store differ diff --git a/arm_diags/arm_driver.py b/arm_diags/arm_driver.py index b8f6ab7..ddbf317 100644 --- a/arm_diags/arm_driver.py +++ b/arm_diags/arm_driver.py @@ -4,6 +4,7 @@ import numpy import cdutil import genutil +import shutil import cdms2 import MV2 import glob @@ -20,13 +21,18 @@ from src.pdf_daily import pdf_daily_data, pdf_daily_plot # .src from src.convection_onset_driver import convection_onset # .src from src.aerosol_activation import aerosol_activation_density_plot # .src -#from src.convection_onset_driver_todd import convection_onset -from src.create_htmls import annual_cycle_zt_html,diurnal_cycle_zt_html,diurnal_cycle_html,seasonal_mean_table_html,annual_cycle_html,annual_cycle_aci_html,pdf_daily_html,convection_onset_html,aerosol_activation_html,diags_main_html +from src.twolegged_metric import twolegged_metric_plot # .src +from src.diurnal_cycle_LAcoupling import diurnal_cycle_LAcoupling_plot +#from src.convection_onset_driver_todd import convection_onset +from src.create_htmls import annual_cycle_zt_html,diurnal_cycle_zt_html,diurnal_cycle_html,seasonal_mean_table_html,annual_cycle_html,annual_cycle_aci_html,pdf_daily_html,convection_onset_html,aerosol_activation_html,twolegged_metric_html,diurnal_cycle_LAcoupling_html,diags_main_html def make_parameters(basic_parameter): #f_data = open('examples/diags_set3.json').read() #f_data = open('diags_all_multisites_for_cmip5.json').read() f_data = open('diags_all_multisites_for_cmip6.json').read() + #f_data = open('diags_set10_cmip6.json').read() + #f_data = open('diags_all_multisites_for_LAcoupling.json').read() + #f_data = open('diags_all_multisites_check.json').read() json_file = json.loads(f_data) parameters = [] @@ -48,9 +54,10 @@ def make_parameters(basic_parameter): #basic_parameter = parser.get_parameters() parameters = make_parameters(basic_parameter) - case_id = basic_parameter.case_id output_path = basic_parameter.output_path +armdiags_path = basic_parameter.armdiags_path +print('output_path: ',output_path) # Generate new case folder given case_id: if not os.path.exists(os.path.join(output_path)): @@ -59,6 +66,13 @@ def make_parameters(basic_parameter): os.makedirs(os.path.join(output_path,'figures')) os.makedirs(os.path.join(output_path,'metrics')) +# Copy the logo figures to the newly created html folder +src = os.listdir(armdiags_path+'arm_diags/misc/') +dst = output_path+'/html/' +for ifile in range(len(src)): + src1 = armdiags_path+'arm_diags/misc/'+src[ifile] + shutil.copy(src1, dst) + # Loop through diagnostic sets prespecified from diags_sets.json html_count = 0 for parameter in parameters: @@ -138,7 +152,18 @@ def make_parameters(basic_parameter): html_count = html_count + 1 #except: #pass - + + if diags_set == 'set10_twolegged_metric': + twolegged_metric_plot(parameter) + twolegged_metric_html(parameter) + html_count = html_count + 1 + + if diags_set == 'set11_diurnal_cycle_LAcoupling': + diurnal_cycle_LAcoupling_plot(parameter) + diurnal_cycle_LAcoupling_html(parameter) + html_count = html_count + 1 + + # if html_count >= 1: # Creat the main html page hosting all sets of diagnostics diff --git a/arm_diags/basicparameter.py b/arm_diags/basicparameter.py index 0ff8a73..659c62f 100644 --- a/arm_diags/basicparameter.py +++ b/arm_diags/basicparameter.py @@ -5,7 +5,11 @@ #--------------------------------------------------------------------------------------------------------------------------- #=========================================================================================================================== # User defined case id -case_id = 'V3_TestCMIP6' +#case_id = 'output_cheng_20230705_mdtfv3_cesm' +case_id = 'output_cheng_20240905_armdiags_v4' + +# User defined the ARM-Diags package path +armdiags_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/arm-gcm-diagnostics/' #-------------------------------------------------------------------------- # Testing model dataset (User defined model) @@ -13,20 +17,27 @@ test_data_set = 'testmodel' #specify the data starting/ending years in the testmodel file #default is 1979 - 2006 as in the CMIP file -test_start_year = 1979 + +#NCAR: 2013, 2014 +#GFDL: 1980, 2000 +test_start_year = 1979 test_end_year = 2006 #-------------------------------------------------------------------------- # Set input path, where the model, observational and cmip data are located. -base_path = '/DATA/ARM-Diag/arm-gcm-diagnostics/arm_diags/' - +#base_path = '/DATA/ARM-Diag/arm-gcm-diagnostics/arm_diags/' +#base_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/arm_diags_data_v3.1_07052023_mdtfv3_cesm/' +#base_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/arm_diags_data_v3.1_05192023/' +#base_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/arm_diags_data_v3.1_06292023_mdtfv3_gfdl/' +base_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/arm_diags_data_v3.1_06122023/' test_data_path = base_path+'testmodel' obs_path = base_path+'observation' cmip_path = base_path+'cmip6' #-------------------------------------------------------------------------- # Set output path, where the results will be saved -output_path = '/DATA/ARM-Diag/Results/'+case_id +#output_path = '/DATA/ARM-Diag/Results/'+case_id +output_path = '/Users/tao4/Documents/ARM_Infrastructure/ARM_DIAG/'+case_id arm_filename = True #=========================================================================================================================== diff --git a/arm_diags/diags_all_multisites_for_cmip6.json b/arm_diags/diags_all_multisites_for_cmip6.json index b4b36f9..afee4ff 100644 --- a/arm_diags/diags_all_multisites_for_cmip6.json +++ b/arm_diags/diags_all_multisites_for_cmip6.json @@ -283,7 +283,22 @@ "diags_set": "set9_aerosol_activation", "variables": ["cpc","ccn"], "sites": ["enac1"] + }, + { + "diags_set": "set10_twolegged_metric", + "variables": ["Atmospheric Coupling Legs","Terrestrial Cooupling Legs"], + "sites": ["sgpc1"], + "season": ["DJF","MAM","JJA","SON"] + }, + { + "diags_set": "set11_diurnal_cycle_LAcoupling", + "variables": ["SH","LH","T_srf","RH_srf","LCL","pbl"], + "varnames": ["Surface Sensible Heat Flux","Surface Latent Heat Flux","Surface Air Temperature","Surface Relative Humidity","Lifting Condensation Level","Planatary Boundary Layer"], + "units": ["W/m\u00b2","W/m\u00b2","deg C","%","meter","meter"], + "sites": ["sgpc1"], + "season": ["ANN","DJF","MAM","JJA","SON"] } + ] } diff --git a/arm_diags/src/annual_cycle_zt.py b/arm_diags/src/annual_cycle_zt.py index aa49127..05794d8 100644 --- a/arm_diags/src/annual_cycle_zt.py +++ b/arm_diags/src/annual_cycle_zt.py @@ -344,8 +344,10 @@ def annual_cycle_zt_plot(parameter): if test_findex == 1: ct_up=np.nanmax([cl_ob,cl_p]) tmpct=cl_p[:,::-1]-cl_ob[:,::-1] - ct_lo_diff=np.int(np.nanmin(tmpct)-1) - ct_up_diff=np.int(np.nanmax(tmpct)+1) + + ct_lo_diff=int(np.nanmin(tmpct)-1) + ct_up_diff=int(np.nanmax(tmpct)+1) + rlevel=np.arange(ct_lo,ct_up+1,0.5) #original drlevel=np.arange(ct_lo_diff,ct_up_diff,0.5) #difference #---------------------------------------------- diff --git a/arm_diags/src/convection_onset_driver.py b/arm_diags/src/convection_onset_driver.py index b875522..7385545 100644 --- a/arm_diags/src/convection_onset_driver.py +++ b/arm_diags/src/convection_onset_driver.py @@ -86,10 +86,10 @@ def convection_onset(parameter): else: filename = glob.glob(os.path.join(obs_path,site[:3]+'armdiags1hr' + site[3:5].upper()+'*.nc'))[0] - print(filename) + print('filename: ',filename) f_in=cdms2.open(filename) var=f_in(va) - print('var_shape',va,var.shape) + print('var_shape: ',va,var.shape) if va == 'pr': precip = var precip[precip<-900] = np.nan diff --git a/arm_diags/src/convection_onset_statistics.py b/arm_diags/src/convection_onset_statistics.py index aa56942..bfebbdf 100644 --- a/arm_diags/src/convection_onset_statistics.py +++ b/arm_diags/src/convection_onset_statistics.py @@ -70,13 +70,14 @@ def convection_onset_statistics(precip_threshold,cwv_max,cwv_min,bin_width,cwv,p #cwv_max = 85 # default = 70 (in mm) #cwv_min = 28 # default = 28 (in mm) #bin_width = 1.5 # default = 1.5 + #print('inputs: ',cwv_max,cwv_min,bin_width) number_of_bins = int(np.ceil((cwv_max-cwv_min)/bin_width)) - #print('cwv_max',cwv_max) - #print(number_of_bins) + #print('number_of_bins: ',number_of_bins) bin_center = np.arange((cwv_min+(bin_width/2)), (cwv_max-(bin_width/2))+bin_width, bin_width) #print('bin_center',bin_center,'bin_width',bin_width) if len(bin_center)!=number_of_bins: bin_center = np.arange((cwv_min+(bin_width/2)), (cwv_max-(bin_width/2)), bin_width) + #print('bin_center range: ',np.min(bin_center),np.max(bin_center)) # Define precip threshold #precip_threshold = 0.5 # default 0.5 (in mm/hr) @@ -86,8 +87,14 @@ def convection_onset_statistics(precip_threshold,cwv_max,cwv_min,bin_width,cwv,p precip_binned = np.empty([number_of_bins,cwv.size]) * np.nan precip_counts = np.zeros([number_of_bins,cwv.size]) - np.warnings.filterwarnings('ignore') + #============================================ + # Cheng 09/05/2024 + # Comment out the following line. + # Otherwise, the figures cannot be generated + #========================================== + #np.warnings.filterwarnings('ignore') # Bin the data by CWV value as specified above + print("Bin the data by CWV value as specified above") for i in range (0,number_of_bins): tmp1 = np.where(cwv > cwv_min+(i*bin_width)) bin_index[i,tmp1] = 1 @@ -116,6 +123,7 @@ def convection_onset_statistics(precip_threshold,cwv_max,cwv_min,bin_width,cwv,p # precip_counts[i,j] = 1 if np.isnan(precip_binned[i,j]): precip_counts[i,j] = np.nan + #print('Check') # Create binned arrays hist_cwv = np.empty([number_of_bins,1]) * np.nan @@ -175,19 +183,19 @@ def convection_onset_statistics(precip_threshold,cwv_max,cwv_min,bin_width,cwv,p xulim = 5*np.ceil(np.max(np.round(bin_center+bin_width/2))/5) xllim = 5*np.floor(np.min(np.round(bin_center-bin_width/2))/5) ax1.set_xlim(xllim-10,xulim+15) - ax1.set_ylim(0,5) + #ax1.set_ylim(0,5) ax1.set_xticks(np.arange(np.ceil(xllim/10)*10-10,np.ceil(xulim/10)*10+15,15)) #print(np.arange(np.ceil(xllim/10)*10-10,np.ceil(xulim/10)*10+15,15)) #print(np.ceil(xllim/10)*10) #print(np.ceil(xulim/10)*10) ulim = np.nanmax(pr_binned_mean) #print('max precip',ulim) - #ax1.set_yticks(np.arange(0,np.ceil(ulim))) - ax1.set_yticks(np.arange(0,5)) + ax1.set_yticks(np.arange(0,np.ceil(ulim))) + #ax1.set_yticks(np.arange(0,5)) #ax1.set_xlim(25,72) #ax1.set_ylim(0,6) #ax1.set_xticks([30,40,50,60,70]) - #ax1.set_yticks([0,1,2,3,4,5,6]) + ax1.set_yticks([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) ax1.tick_params(labelsize=axes_fontsize) ax1.tick_params(axis='x', pad=10) error = [errorbar_precip,errorbar_precip] diff --git a/arm_diags/src/create_htmls.py b/arm_diags/src/create_htmls.py index f84d760..ec9930c 100644 --- a/arm_diags/src/create_htmls.py +++ b/arm_diags/src/create_htmls.py @@ -1,11 +1,11 @@ #=========================================================================================================================== # Program for generate the HTML files hosting the results -- Original written by Dr. Chengzhu Zhang @ LLNL #--------------------------------------------------------------------------------------------------------------------------- -# V3 Development +# V4 Development # --------------------------------------------------------------------------------------- - # Xiaojian Zheng - Dec 2021 - # ### change the input/output format to site-dependent (ENA/MAO added) - # ### fix minor issues on image linking + # Cheng Tao - Jul, 2024 + # ### Edit the name of some of metrics + # ### Fix the links of sampled figures # --------------------------------------------------------------------------------------- #=========================================================================================================================== import csv @@ -28,13 +28,13 @@ def diags_main_html(output_path,test_model):
- ARM data-oriented Diagnostics package (ARM-DIAGS-V3) + ARM data-oriented Diagnostics package (ARM-DIAGS-V4)
Metrics and Diagnostics
Model: """+test_model+"""
@@ -44,36 +44,39 @@ def diags_main_html(output_path,test_model):
2 Line plots and Taylor diagrams of Annual Cycle.
- 3 Line plots and Taylor diagrams of ACI Annual Cycle.
- 4 Contour and Vertical profiles of Annual Cycle.
- 5 Line and Harmonic Dail plots of Diurnal Cycle.
- 6 Contour plots of Diurnal Cycle.
7 Line plots of Probability Density Function.
+ 8 Line plots of Land-Atmosphere Coupling Diurnal Cycle.
| - | + |
Process-oriented Diagnostics Sets
1 Basic diagnostics plots for Convection Onset.
2 Basic diagnostics plots for Aerosol Activation.
+ 3 Basic diagnostics plots for Two-legged metrics. |
---|
{} | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'+variables[j]+' (Obs. vs. Model)')
+
+ for season in seasons:
+ #Atmospheric component
+ two_figs_atm = 'twolegged_metric_atm_'+season+'_'+title_name+'.html'
+ htmlfile_atm = open(output_path+'/html/'+two_figs_atm,"w")
+ fig1='../figures/{}/'.format(title_name)+'Scatter_plot_'+season+'_atmos_component_obs_{}.png'.format(title_name)
+ fig2='../figures/{}/'.format(title_name)+'Scatter_plot_'+season+'_atmos_component_testmod_{}.png'.format(title_name)
+ #print(fig2)
+
+ htmlfile_atm.write(' ')
+
+ #Terrestrial component
+ two_figs_land = 'twolegged_metric_land_'+season+'_'+title_name+'.html'
+ htmlfile_land = open(output_path+'/html/'+two_figs_land,"w")
+ fig1='../figures/{}/'.format(title_name)+'Scatter_plot_'+season+'_land_component_obs_{}.png'.format(title_name)
+ fig2='../figures/{}/'.format(title_name)+'Scatter_plot_'+season+'_land_component_testmod_{}.png'.format(title_name)
+ htmlfile_land.write(' ')
+
+ if j==0:
+ htmlfile.write(' '+season+'')
+ elif j==1:
+ htmlfile.write(' | '+season+'')
+
+ htmlfile.write(' | '+test_model+': Land-Atmosphere Coupling Diurnal Cycle'+ ' | ')
+ htmlfile.write('
|