Skip to content

Commit

Permalink
Snapshot of scripts at time thesis is completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantheory committed Nov 23, 2020
1 parent a22aa0e commit b2abaaf
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 38 deletions.
16 changes: 8 additions & 8 deletions create_climos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

CASE_NAMES="timestep_ctrl timestep_all_10s"
CASE_NAMES="timestep_ctrl"
MONTHS="01 02"
INPUT_DIR=/p/lscratchh/santos36/timestep_monthly_avgs_lat_lon
OUTPUT_DIR=/p/lscratchh/santos36/timestep_monthly_avgs_lat_lon
Expand All @@ -10,7 +10,7 @@ for case_name in $CASE_NAMES; do
for month in $MONTHS; do
date
echo "On month $month."
ncra $INPUT_DIR/$case_name.00{02,03,04}-$month.nc $OUTPUT_DIR/${case_name}_${month}_climo.nc
ncra $INPUT_DIR/$case_name.00{05,06,07}-$month.nc $OUTPUT_DIR/${case_name}_y04-y07_${month}_climo.nc
done
done

Expand All @@ -21,20 +21,20 @@ for case_name in $CASE_NAMES; do
for month in $MONTHS; do
date
echo "On month $month."
ncra $INPUT_DIR/$case_name.00{01,02,03}-$month.nc $OUTPUT_DIR/${case_name}_${month}_climo.nc
ncra $INPUT_DIR/$case_name.00{04,05,06}-$month.nc $OUTPUT_DIR/${case_name}_y04-y07_${month}_climo.nc
done
done

for case_name in $CASE_NAMES; do
echo "On case $case_name"
echo "Seasonal average DJF"
ncra -w 31,31,28 $OUTPUT_DIR/${case_name}_{12,01,02}_climo.nc $OUTPUT_DIR/${case_name}_DJF_climo.nc
ncra -w 31,31,28 $OUTPUT_DIR/${case_name}_y04-y07_{12,01,02}_climo.nc $OUTPUT_DIR/${case_name}_y04-y07_DJF_climo.nc
echo "Seasonal average MAM"
ncra -w 31,30,31 $OUTPUT_DIR/${case_name}_{03,04,05}_climo.nc $OUTPUT_DIR/${case_name}_MAM_climo.nc
ncra -w 31,30,31 $OUTPUT_DIR/${case_name}_y04-y07_{03,04,05}_climo.nc $OUTPUT_DIR/${case_name}_y04-y07_MAM_climo.nc
echo "Seasonal average JJA"
ncra -w 30,31,31 $OUTPUT_DIR/${case_name}_{06,07,08}_climo.nc $OUTPUT_DIR/${case_name}_JJA_climo.nc
ncra -w 30,31,31 $OUTPUT_DIR/${case_name}_y04-y07_{06,07,08}_climo.nc $OUTPUT_DIR/${case_name}_y04-y07_JJA_climo.nc
echo "Seasonal average SON"
ncra -w 30,31,30 $OUTPUT_DIR/${case_name}_{09,10,11}_climo.nc $OUTPUT_DIR/${case_name}_SON_climo.nc
ncra -w 30,31,30 $OUTPUT_DIR/${case_name}_y04-y07_{09,10,11}_climo.nc $OUTPUT_DIR/${case_name}_y04-y07_SON_climo.nc
echo "Annual average"
ncra -w 31,28,31,30,31,30,31,31,30,31,30,31 $OUTPUT_DIR/${case_name}_{01,02,03,04,05,06,07,08,09,10,11,12}_climo.nc $OUTPUT_DIR/${case_name}_ANN_climo.nc
ncra -w 31,28,31,30,31,30,31,31,30,31,30,31 $OUTPUT_DIR/${case_name}_y04-y07_{01,02,03,04,05,06,07,08,09,10,11,12}_climo.nc $OUTPUT_DIR/${case_name}_y04-y07_ANN_climo.nc
done
2 changes: 1 addition & 1 deletion create_daily_averages.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

CASE_NAMES="timestep_all_10s timestep_CLUBB_10s timestep_CLUBB_MG2_10s timestep_MG2_10s timestep_dyn_10s timestep_CLUBB_MG2_60s"
CASE_NAMES="timestep_CLUBB_MG2_Strang_60s"
DAYS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"
OUTPUT_DIR=/p/lscratchh/santos36/timestep_daily_avgs

Expand Down
6 changes: 3 additions & 3 deletions create_monthly_averages.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

CASE_NAMES="timestep_all_10s"
MONTHS="03 04 05 06 07 08 09 10 11 12"
CASE_NAMES="timestep_ctrl"
MONTHS="01"
OUTPUT_DIR=/p/lscratchh/santos36/timestep_monthly_avgs

for case_name in $CASE_NAMES; do
Expand All @@ -10,6 +10,6 @@ for case_name in $CASE_NAMES; do
for month in $MONTHS; do
date
echo "On month $month."
ncra $case_dir/$case_name.cam.h0.0002-$month-* $OUTPUT_DIR/$case_name.0002-$month.nc
ncra $case_dir/$case_name.cam.h0.0007-$month-* $OUTPUT_DIR/$case_name.0007-$month.nc
done
done
2 changes: 1 addition & 1 deletion create_precip_hourly.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

CASE_NAMES="timestep_all_10s"
CASE_NAMES="timestep_ctrl"
MONTHS="03 04 05 06 07 08 09 10 11 12"
OUTPUT_DIR=/p/lscratchh/santos36/timestep_precip

Expand Down
2 changes: 2 additions & 0 deletions plot_compare_2D_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def inverse(a):
E3SMCaseOutput("timestep_MG2_10s", "MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s", "CLUBB10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s_MG2_10s", "CLUBB10MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang", "CLUBBMICROSTR", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang_60s", "CLUBBMICROSTR60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_10s", "CLUBBMICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_60s", "CLUBBMICRO60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_ZM_10s", "ZM10", DAILY_FILE_LOC, START_DAY, END_DAY),
Expand Down
4 changes: 2 additions & 2 deletions plot_compare_2D_vars_monthly.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def inverse(a):
a = np.arcsin(a)
return np.rad2deg(a)

START_YEAR = 1
START_MONTH = 3
START_YEAR = 3
START_MONTH = 12
END_YEAR = 4
END_MONTH = 2

Expand Down
4 changes: 3 additions & 1 deletion plot_compare_3D_zonal_avg_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def inverse(a):

DAILY_FILE_LOC="/p/lscratchh/santos36/timestep_daily_avgs_lat_lon"

USE_PRESAER = True
USE_PRESAER = False

days = list(range(START_DAY, END_DAY+1))
ndays = len(days)
Expand Down Expand Up @@ -51,6 +51,8 @@ def inverse(a):
E3SMCaseOutput("timestep_MG2_10s", "MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s", "CLUBB10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s_MG2_10s", "CLUBB10MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang", "CLUBBMICROSTR", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang_60s", "CLUBBMICROSTR60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_10s", "CLUBBMICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_60s", "CLUBBMICRO60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_ZM_10s", "ZM10", DAILY_FILE_LOC, START_DAY, END_DAY),
Expand Down
4 changes: 4 additions & 0 deletions plot_daily_means.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
E3SMCaseOutput("timestep_dyn_10s", "DYN10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s", "CLUBB10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_10s_MG2_10s", "CLUBB10MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang", "CLUBBMICROSTR", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_Strang_60s", "CLUBBMICROSTR60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_MG2_10s", "MICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_60s", "CLUBBMICRO60", DAILY_FILE_LOC, START_DAY, END_DAY),
E3SMCaseOutput("timestep_CLUBB_MG2_10s", "CLUBBMICRO10", DAILY_FILE_LOC, START_DAY, END_DAY),
Expand All @@ -77,6 +79,8 @@
"CLUBB10": ('b', '-'),
"MICRO10": ('r', '-'),
"CLUBB10MICRO10": ('maroon', '-'),
"CLUBBMICROSTR": ('m', '-'),
"CLUBBMICROSTR60": ('m', '--'),
"CLUBBMICRO60": ('indigo', '--'),
"CLUBBMICRO10": ('indigo', '-'),
"ALL10": ('dimgrey', '-'),
Expand Down
11 changes: 6 additions & 5 deletions plot_precip_freq.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
ncol = len(first_file.dimensions['ncol'])
nbins = len(first_file.dimensions['nbins'])
bin_lower_bounds = first_file['bin_lower_bounds'][:]
bin_width = np.log(bin_lower_bounds[2] / bin_lower_bounds[1])
lat = first_file['lat'][:]
lon = first_file['lon'][:]
area = first_file['area'][:]
Expand Down Expand Up @@ -128,17 +129,17 @@
plt.title("Frequency distribution of precipitation ({}/{}-{}/{})".format(
day_str(START_MONTH), day_str(START_YEAR),
day_str(END_MONTH), day_str(END_YEAR)))
plt.xlabel("Precipitation amount (mm/day)")
plt.xlabel("Precipitation intensity (mm/day)")
plt.ylabel("fraction")
plt.savefig("{}_freq{}.png".format(var, suffix))
plt.close()

plt.semilogx(bin_lower_bounds[1:], ref_amount_avgs[var][1:], 'k')
plt.semilogx(bin_lower_bounds[1:], test_amount_avgs[var][1:], 'r')
plt.semilogx(bin_lower_bounds[1:], ref_amount_avgs[var][1:] / bin_width, 'k')
plt.semilogx(bin_lower_bounds[1:], test_amount_avgs[var][1:] / bin_width, 'r')
plt.title("Amounts of precipitation ({}/{}-{}/{})".format(
day_str(START_MONTH), day_str(START_YEAR),
day_str(END_MONTH), day_str(END_YEAR)))
plt.xlabel("Precipitation amount (mm/day)")
plt.ylabel("Average amount (mm/day)")
plt.xlabel("Precipitation intensity (mm/day)")
plt.ylabel("Average precipitation amount (mm/day)")
plt.savefig("{}_amount{}.png".format(var, suffix))
plt.close()
64 changes: 55 additions & 9 deletions plot_precip_freq_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,30 @@

from e3sm_case_output import day_str

REF_CASE_NAME = "timestep_all_300s"
TEST_CASE_NAMES = ["timestep_CLUBB_MG2_10s", "timestep_all_60s"]
SHORT_TEST_CASE_NAMES = ["CLUBBMICRO10", "ALL60"]
OUTPUT_DIR = "/p/lustre2/santos36/timestep_precip/"

USE_PRESAER = False
TROPICS_ONLY = True
TROPICS_ONLY = False

START_DAY = 3
END_DAY = 15

if USE_PRESAER:
REF_CASE_NAME = "timestep_presaer_ctrl"
TEST_CASE_NAMES = [
"timestep_presaer_ZM_10s",
"timestep_presaer_CLUBB_MG2_10s",
"timestep_presaer_CLUBB_MG2_10s_ZM_10s",
"timestep_presaer_cld_10s",
"timestep_presaer_all_10s",
]
SHORT_TEST_CASE_NAMES = [
"ZM10PA",
"CLUBBMICRO10PA",
"CLUBBMICRO10ZM10PA",
"CLD10PA",
"ALL10PA",
]
STYLES = {
"CLUBBMICRO10PA": ('indigo', '-'),
"ALL10PA": ('dimgrey', '-'),
Expand All @@ -30,11 +42,42 @@
"CLD10PA": ('slateblue', '-'),
}
else:
REF_CASE_NAME = "timestep_ctrl"
TEST_CASE_NAMES = [
"timestep_dyn_10s",
"timestep_CLUBB_10s",
"timestep_MG2_10s",
"timestep_CLUBB_10s_MG2_10s",
"timestep_CLUBB_MG2_Strang",
"timestep_CLUBB_MG2_Strang_60s",
"timestep_CLUBB_MG2_60s",
"timestep_CLUBB_MG2_10s",
"timestep_all_10s",
"timestep_all_60s",
"timestep_all_300s",
"timestep_all_rad_10s",
]
SHORT_TEST_CASE_NAMES = [
"DYN10",
"CLUBB10",
"MICRO10",
"CLUBB10MICRO10",
"CLUBBMICROSTR",
"CLUBBMICROSTR60",
"CLUBBMICRO60",
"CLUBBMICRO10",
"ALL10",
"ALL60",
"ALL300",
"ALLRAD10",
]
STYLES = {
"DYN10": ('y', '-'),
"CLUBB10": ('b', '-'),
"MICRO10": ('r', '-'),
"CLUBB10MICRO10": ('maroon', '-'),
"CLUBBMICROSTR": ('m', '-'),
"CLUBBMICROSTR60": ('m', '--'),
"CLUBBMICRO60": ('indigo', '--'),
"CLUBBMICRO10": ('indigo', '-'),
"ALL10": ('dimgrey', '-'),
Expand All @@ -47,6 +90,8 @@

suffix = '_d{}-d{}'.format(day_str(START_DAY), day_str(END_DAY))

if USE_PRESAER:
suffix += '_presaer'
if TROPICS_ONLY:
suffix += '_tropics'

Expand All @@ -59,6 +104,7 @@
ncol = len(first_file.dimensions['ncol'])
nbins = len(first_file.dimensions['nbins'])
bin_lower_bounds = first_file['bin_lower_bounds'][:]
bin_width = np.log(bin_lower_bounds[2] / bin_lower_bounds[1])
lat = first_file['lat'][:]
lon = first_file['lon'][:]
area = first_file['area'][:]
Expand Down Expand Up @@ -134,19 +180,19 @@
linestyle=STYLES[SHORT_TEST_CASE_NAMES[i]][1])
plt.title("Frequency distribution of precipitation (days {}-{})".format(
day_str(START_DAY), day_str(END_DAY)))
plt.xlabel("Precipitation amount (mm/day)")
plt.xlabel("Precipitation intensity (mm/day)")
plt.ylabel("fraction")
plt.savefig("{}_freq{}.png".format(var, suffix))
plt.close()

plt.semilogx(bin_lower_bounds[1:], ref_amount_avgs[var][1:], 'k')
plt.semilogx(bin_lower_bounds[1:], ref_amount_avgs[var][1:] / bin_width, 'k')
for i in range(num_tests):
plt.semilogx(bin_lower_bounds[1:], test_amount_avgs[i][var][1:],
plt.semilogx(bin_lower_bounds[1:], test_amount_avgs[i][var][1:] / bin_width,
color=STYLES[SHORT_TEST_CASE_NAMES[i]][0],
linestyle=STYLES[SHORT_TEST_CASE_NAMES[i]][1])
plt.title("Amounts of precipitation (days {}-{})".format(
day_str(START_DAY), day_str(END_DAY)))
plt.xlabel("Precipitation amount (mm/day)")
plt.ylabel("Average amount (mm/day)")
plt.xlabel("Precipitation intensity (mm/day)")
plt.ylabel("Average precipitation amount (mm/day)")
plt.savefig("{}_amount{}.png".format(var, suffix))
plt.close()
3 changes: 2 additions & 1 deletion plot_taylor_timestep.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ def std(variable, axis='xy'):
case_colors = {
'timestep_all_10s': 'k',
'timestep_ctrl_ne16': 'r',
'timestep_ctrl_y04-y07': 'g',
}

for season in parameter.seasons:
# Will not actually work for multiple seasons as written due to having only
# one figure.
print('Season: {}'.format(season))

for test_name in ('timestep_all_10s', 'timestep_ctrl_ne16'):
for test_name in ('timestep_all_10s', 'timestep_ctrl_ne16', 'timestep_ctrl_y04-y07'):
parameter.test_name = test_name
test_data = utils.dataset.Dataset(parameter, test=True)

Expand Down
4 changes: 2 additions & 2 deletions regrid_daily_avgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
REMAP_FILE=/usr/gdata/climdat/maps/map_ne30np4_to_fv128x256_aave.20160301.nc
IN_DIR=/p/lscratchh/santos36/timestep_daily_avgs
OUT_DIR=/p/lscratchh/santos36/timestep_daily_avgs_lat_lon
CASE_NAMES="timestep_all_rad_10s"
DAYS="20 21 22 23 24 25 26 27 28 29 30"
CASE_NAMES="timestep_CLUBB_MG2_Strang_60s"
DAYS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"

for case_name in $CASE_NAMES; do
date
Expand Down
12 changes: 9 additions & 3 deletions regrid_monthly_avgs.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/bin/sh

REMAP_FILE_NE30=/usr/gdata/climdat/maps/map_ne16np4_to_ne30np4_aave.20160601.nc
REMAP_FILE=/usr/gdata/climdat/maps/map_ne30np4_to_fv128x256_aave.20160301.nc
IN_DIR=/p/lscratchh/santos36/timestep_monthly_avgs
OUT_DIR=/p/lscratchh/santos36/timestep_monthly_avgs_lat_lon
CASE_NAMES="timestep_ctrl timestep_all_10s"
MONTHS="01 02"
CASE_NAMES="timestep_ctrl"
#MONTHS="01 02 03 04 05 06 07 08 09 10 11 12"
MONTHS="01"
YEAR="0007"

for case_name in $CASE_NAMES; do
date
echo "On case $case_name"
filenames=
for month in $MONTHS; do
date
echo "On month $month"
ncremap -m $REMAP_FILE -O $OUT_DIR $IN_DIR/$case_name.0004-$month.nc
filenames="$filenames $IN_DIR/$case_name.$YEAR-$month.nc"
# ncremap -m $REMAP_FILE_NE30 -o $IN_DIR/$case_name.$YEAR-$month.nc $IN_DIR/$case_name.cam.h0.$YEAR-$month.nc
done
ls $filenames | ncremap -p bck -j 12 -m $REMAP_FILE -O $OUT_DIR
done
2 changes: 1 addition & 1 deletion write_precip_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
bins = np.logspace(BINS_BOUNDS[0], BINS_BOUNDS[1], NUM_BINS-1)

START_YEAR = 3
START_MONTH = 3
START_MONTH = 8
END_YEAR = 3
END_MONTH = 12

Expand Down
2 changes: 1 addition & 1 deletion write_precip_histogram_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from e3sm_case_output import day_str, time_str

CASE_NAME = "timestep_presaer_CLUBB_MG2_10s_ZM_10s"
CASE_NAME = "timestep_CLUBB_MG2_Strang_60s"
CASE_DIR = "/p/lscratchh/santos36/ACME/{}/run".format(CASE_NAME)
OUTPUT_DIR = "/p/lustre2/santos36/timestep_precip/"
NUM_BINS = 101
Expand Down

0 comments on commit b2abaaf

Please sign in to comment.