From 9ee4a8f0e4df56b5a1bf2bf25b23f82f8d23793f Mon Sep 17 00:00:00 2001 From: Hsiang-He Lee Date: Wed, 9 Aug 2023 18:26:00 -0500 Subject: [PATCH 1/2] Replace 'AREA' by using 'area' --- chemdyg/templates/chemdyg_TOZ_eq_plot.bash | 9 ++++++--- chemdyg/templates/chemdyg_nox_emis_plots.bash | 3 ++- chemdyg/templates/chemdyg_o3_hole_diags.bash | 7 ++++--- chemdyg/templates/chemdyg_temperature_eq_plot.bash | 14 +++++++++----- setup.cfg | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/chemdyg/templates/chemdyg_TOZ_eq_plot.bash b/chemdyg/templates/chemdyg_TOZ_eq_plot.bash index 7db84f3..2df4d62 100644 --- a/chemdyg/templates/chemdyg_TOZ_eq_plot.bash +++ b/chemdyg/templates/chemdyg_TOZ_eq_plot.bash @@ -122,9 +122,12 @@ endyear = ${y2} lat = file_in['lat'] lat2 = refer['lat'] +rearth = 6.37122e6 +AREA_in = refer['area'] * rearth * rearth + TOZ_sel = file_in['TCO'].where((lat < -60), drop=True)+file_in['SCO'].where((lat < -60), drop=True) -AREA_sel = refer['AREA'].where((lat2 < -60), drop=True) -AREA_64S = refer['AREA'].where((lat2 < -64), drop=True).sum() +AREA_sel = AREA_in.where((lat2 < -60), drop=True) +AREA_64S = AREA_in.where((lat2 < -64), drop=True).sum() AREA_64S = np.array(AREA_64S) TOZ_min = TOZ_sel.min(axis=1) @@ -138,7 +141,7 @@ O3_64S = np.zeros(years*365) for i in range(startindex,endindex): ii = i - startindex - d = {'TOZ': np.array(TOZ_sel[i]), 'AREA': np.array(AREA_sel[0])} + d = {'TOZ': np.array(TOZ_sel[i]), 'AREA': np.array(AREA_sel)} df = pd.DataFrame(data=d) df_sort = df.sort_values(by=['TOZ']) diff --git a/chemdyg/templates/chemdyg_nox_emis_plots.bash b/chemdyg/templates/chemdyg_nox_emis_plots.bash index fd59cc4..a7f816e 100644 --- a/chemdyg/templates/chemdyg_nox_emis_plots.bash +++ b/chemdyg/templates/chemdyg_nox_emis_plots.bash @@ -119,7 +119,8 @@ filename = short_name+'_ANN_'+startyear+'01_'+endyear+'12_climo.nc' file_in = xr.open_dataset(path+filename) -AREA = file_in['AREA'][0,:,:] #m2 +rearth = 6.37122e6 +AREA = file_in['area'] * rearth * rearth #m2 lat = file_in['lat'] lon = file_in['lon'] lev = file_in['lev'] diff --git a/chemdyg/templates/chemdyg_o3_hole_diags.bash b/chemdyg/templates/chemdyg_o3_hole_diags.bash index 46015af..b75994e 100644 --- a/chemdyg/templates/chemdyg_o3_hole_diags.bash +++ b/chemdyg/templates/chemdyg_o3_hole_diags.bash @@ -134,10 +134,11 @@ startyear = ${y1} endyear = ${y2} years = endyear - startyear + 1 lat = refer['lat'] -AREA_sel = refer['AREA'] +rearth = 6.37122e6 +AREA_in = refer['area'] * rearth * rearth TOZ_sel = file_in['TCO'].where((lat < 0), drop=True)+file_in['SCO'].where((lat < 0), drop=True) -AREA_sel = refer['AREA'].where((lat < 0), drop=True) +AREA_sel = AREA_in.where((lat < 0), drop=True) TOZ_min = TOZ_sel.min(axis=1) t_period = len(TOZ_sel) @@ -149,7 +150,7 @@ endindex = startindex + years*365 O3_area = TOZ_min.copy() for i in range(startindex,endindex): - d = {'TOZ': np.array(TOZ_sel[i]), 'AREA': np.array(AREA_sel[0])} + d = {'TOZ': np.array(TOZ_sel[i]), 'AREA': np.array(AREA_sel)} df = pd.DataFrame(data=d) df_sort = df.sort_values(by=['TOZ']) diff --git a/chemdyg/templates/chemdyg_temperature_eq_plot.bash b/chemdyg/templates/chemdyg_temperature_eq_plot.bash index 38cafad..6e3cbb7 100644 --- a/chemdyg/templates/chemdyg_temperature_eq_plot.bash +++ b/chemdyg/templates/chemdyg_temperature_eq_plot.bash @@ -116,10 +116,14 @@ refer = xr.open_dataset(path+filename+'.eam.h0.${Y1}-01.nc') file_in = xr.open_mfdataset(path+filename+'.${eamfile}.*') lat = file_in['lat'] +lat2 = refer['lat'] +rearth = 6.37122e6 +AREA_in = refer['area'] * rearth * rearth + TOZ_h = file_in['T'][:,13].where((lat < -55), drop=True) TOZ_m = file_in['T'][:,21].where((lat < -55), drop=True) TOZ_l = file_in['T'][:,29].where((lat < -55), drop=True) -AREA_sel = refer['AREA'].where((lat < -55), drop=True) +AREA_sel = AREA_in.where((lat2 < -55), drop=True) TOZ_h_sel = TOZ_h.sel(time=TOZ_h.time.dt.month.isin([6,7,8,9,10,11,12])) TOZ_m_sel = TOZ_m.sel(time=TOZ_m.time.dt.month.isin([6,7,8,9,10,11,12])) TOZ_l_sel = TOZ_l.sel(time=TOZ_l.time.dt.month.isin([6,7,8,9,10,11,12])) @@ -129,7 +133,7 @@ temp_lat_m = np.zeros(10) temp_lat_l = np.zeros(10) for i in range(0,20,2): ilat = i + 60 - AREA_refer = refer['AREA'].where((lat < -ilat), drop=True).sum() + AREA_refer = AREA_in.where((lat2 < -ilat), drop=True).sum() AREA_refer = np.array(AREA_refer) t_period = len(TOZ_h_sel['time']) @@ -139,7 +143,7 @@ for i in range(0,20,2): temp_l = np.zeros(t_period) # height from layer 13 to 29 for t in range(t_period): - dh = {'TOZ': np.array(TOZ_h_sel[t]), 'AREA': np.array(AREA_sel[0])} + dh = {'TOZ': np.array(TOZ_h_sel[t]), 'AREA': np.array(AREA_sel)} dfh = pd.DataFrame(data=dh) dfh_sort = dfh.sort_values(by=['TOZ']) @@ -155,7 +159,7 @@ for i in range(0,20,2): TOZ_h_index = result_h[0].min() temp_h[t] = (TOZ_h_sort[0:TOZ_h_index-1]*AREA_h_sort[0:TOZ_h_index-1]).mean()/(AREA_h_sort[0:TOZ_h_index-1].mean()) # --------- - dm = {'TOZ': np.array(TOZ_m_sel[t]), 'AREA': np.array(AREA_sel[0])} + dm = {'TOZ': np.array(TOZ_m_sel[t]), 'AREA': np.array(AREA_sel)} dfm = pd.DataFrame(data=dm) dfm_sort = dfm.sort_values(by=['TOZ']) @@ -172,7 +176,7 @@ for i in range(0,20,2): temp_m[t] = (TOZ_m_sort[0:TOZ_m_index-1]*AREA_m_sort[0:TOZ_m_index-1]).mean()/(AREA_m_sort[0:TOZ_m_index-1].mean()) # --------- - dl = {'TOZ': np.array(TOZ_l_sel[t]), 'AREA': np.array(AREA_sel[0])} + dl = {'TOZ': np.array(TOZ_l_sel[t]), 'AREA': np.array(AREA_sel)} dfl = pd.DataFrame(data=dl) dfl_sort = dfl.sort_values(by=['TOZ']) diff --git a/setup.cfg b/setup.cfg index 1438ab7..5d639dc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chemdyg -version = 0.1.2 +version = 0.1.3 author = Hsiang-He Lee, Qi Tang, Michael J. Prather, Jean-Christophe Golaz, Xylar Asay-Davis author_email = lee1061@llnl.gov description = E3SM Chemistry Diagnostics Package From 56c92a390c88e90cab7c934933df12ce294ad3ce Mon Sep 17 00:00:00 2001 From: Hsiang-He Lee Date: Thu, 10 Aug 2023 12:03:56 -0500 Subject: [PATCH 2/2] correct the version back to v0.1.2 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 5d639dc..1438ab7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chemdyg -version = 0.1.3 +version = 0.1.2 author = Hsiang-He Lee, Qi Tang, Michael J. Prather, Jean-Christophe Golaz, Xylar Asay-Davis author_email = lee1061@llnl.gov description = E3SM Chemistry Diagnostics Package