def get_prece(case_name):
    file_name = out_file_template.format(case_name, day_str(START_YEAR),
                                         day_str(START_MONTH))
    precip_file = nc4.Dataset(join(PRECIP_OUTPUT_DIR, file_name), 'r')
    nbins = len(precip_file.dimensions['nbins'])
    bin_lower_bounds = precip_file['bin_lower_bounds'][:]
    precip_file.close()
    ibinthresh = -1
    for i in range(nbins):
        if bin_lower_bounds[i] > PRECE_THRESHOLD:
            ibinthresh = i
            break
    if ibinthresh == -1:
        print(
            "Warning: extreme precip threshold greater than largest bin bound."
        )
    prece = np.zeros((nlat, nlon))
    for imonth in imonths:
        month = months[imonth]
        year = years[imonth]
        file_name = out_file_template.format(case_name, day_str(year),
                                             day_str(month))
        precip_file = nc4.Dataset(join(PRECIP_OUTPUT_DIR, file_name), 'r')
        prece += precip_file["PRECT_amount"][:, :, ibinthresh:].sum(axis=2)
        precip_file.close()
    return prece
def get_prece(case_name, start_day, end_day):
    file_name = out_file_template.format(case_name, day_str(start_day),
                                         day_str(end_day))
    precip_file = nc4.Dataset(join(PRECIP_OUTPUT_DIR, file_name), 'r')
    nbins = len(precip_file.dimensions['nbins'])
    bin_lower_bounds = precip_file['bin_lower_bounds'][:]
    ibinthresh = -1
    for i in range(nbins):
        if bin_lower_bounds[i] > PRECE_THRESHOLD:
            ibinthresh = i
            break
    if ibinthresh == -1:
        print(
            "Warning: extreme precip threshold greater than largest bin bound."
        )
    prece = precip_file["PRECT_amount"][:, :, ibinthresh:].sum(axis=2)
    return prece
def inverse(a):
    a = np.arcsin(a)
    return np.rad2deg(a)


START_DAY = 3
END_DAY = 15

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

USE_PRESAER = False

days = list(range(START_DAY, END_DAY + 1))
ndays = len(days)

suffix = '_d{}-{}'.format(day_str(START_DAY), day_str(END_DAY))
if USE_PRESAER:
    suffix += '_presaer'

log_file = open("plot_2D_log{}.txt".format(suffix), 'w')

if USE_PRESAER:
    REF_CASE = E3SMCaseOutput("timestep_presaer_ctrl", "CTRLPA",
                              DAILY_FILE_LOC, START_DAY, END_DAY)
    TEST_CASES = [
        E3SMCaseOutput("timestep_presaer_all_10s", "ALL10PA", DAILY_FILE_LOC,
                       START_DAY, END_DAY),
        E3SMCaseOutput("timestep_presaer_CLUBB_MG2_10s", "CLUBBMICRO10PA",
                       DAILY_FILE_LOC, START_DAY, END_DAY),
        E3SMCaseOutput("timestep_presaer_ZM_10s", "ZM10PA", DAILY_FILE_LOC,
                       START_DAY, END_DAY),
示例#4
0
def get_out_file_name(icase, day, time):
    """Given a case index, day, and time, return CAM header file name."""
    return join(
        OUTPUT_DIRS[icase],
        out_file_template.format(CASE_NAMES[icase], day_str(day),
                                 time_str(time)))
示例#5
0
imonths = list(range(nmonths))
curr_month = START_MONTH
curr_year = START_YEAR
months = []
years = []
for i in range(nmonths):
    months.append(curr_month)
    years.append(curr_year)
    curr_month += 1
    if curr_month > 12:
        curr_month = 1
        curr_year += 1

filename_template = "{}.cam.h0.{}-{}-{}-{}.nc"

first_file_name = filename_template.format(CASE_NAME, "00"+day_str(START_YEAR),
                                           day_str(START_MONTH), day_str(1),
                                           time_str(0))
first_file = nc4.Dataset(join(CASE_DIR, first_file_name), 'r')
ncol = len(first_file.dimensions['ncol'])
lat = first_file['lat'][:]
lon = first_file['lon'][:]
area = first_file['area'][:]
first_file.close()

prec_vars = ("PRECC", "PRECL", "PRECT")# "PRECSC", "PRECSL")

for i in range(nmonths):
    year = years[i]
    year_string = "00" + day_str(year)
    month = months[i]
nmonths = (END_YEAR - START_YEAR) * 12 - (START_MONTH - 1) + END_MONTH
imonths = list(range(nmonths))
curr_month = START_MONTH
curr_year = START_YEAR
months = []
years = []
for i in range(nmonths):
    months.append(curr_month)
    years.append(curr_year)
    curr_month += 1
    if curr_month > 12:
        curr_month = 1
        curr_year += 1

suffix = '_y{}m{}-y{}m{}'.format(day_str(START_YEAR), day_str(START_MONTH),
                                 day_str(END_YEAR), day_str(END_MONTH))

suffix += '_zonal'

log_file = open("plot_zonal_log{}.txt".format(suffix), 'w')

REF_CASE = E3SMCaseOutput("timestep_ctrl", "CTRL", MONTHLY_FILE_LOC,
                          START_MONTH, END_MONTH)
TEST_CASES = [
    E3SMCaseOutput("timestep_all_10s", "ALL10", MONTHLY_FILE_LOC, START_MONTH,
                   END_MONTH),
]

rfile0 = nc4.Dataset(REF_CASE.get_monthly_file_name(START_MONTH, START_YEAR),
                     'r')
        "CLUBB10": ('b', '-'),
        "MICRO10": ('r', '-'),
        "CLUBB10MICRO10": ('maroon', '-'),
        "CLUBBMICROSTR": ('m', '-'),
        "CLUBBMICROSTR60": ('m', '--'),
        "CLUBBMICRO60": ('indigo', '--'),
        "CLUBBMICRO10": ('indigo', '-'),
        "ALL10": ('dimgrey', '-'),
        "ALL60": ('dimgrey', '--'),
        "ALL300": ('dimgrey', ':'),
        "ALLRAD10": ('orange', '-'),
    }

num_tests = len(TEST_CASE_NAMES)

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

if FOCUS_PRECIP:
    suffix += '_precip'
if USE_PRESAER:
    suffix += '_presaer'
if TROPICS_ONLY:
    if LAND_TROPICS:
        suffix += '_lndtropics'
    else:
        suffix += '_tropics'

log_file = open("plot_precip_log{}.txt".format(suffix), 'w')

out_file_template = "{}.freq.short.d{}-d{}.nc"
REF_CASE_NAME = "timestep_ctrl"
TEST_CASE_NAME = "timestep_all_10s"
OUTPUT_DIR = "/p/lustre2/santos36/timestep_precip/"

LAND_TROPICS = True
TROPICS_ONLY = False

if LAND_TROPICS:
    TROPICS_ONLY = True

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

suffix = '_y{}m{}-y{}m{}'.format(day_str(START_YEAR),
                                 day_str(START_MONTH),
                                 day_str(END_YEAR),
                                 day_str(END_MONTH))

if TROPICS_ONLY:
    if LAND_TROPICS:
        suffix += '_lndtropics'
    else:
        suffix += '_tropics'

log_file = open("plot_precip_log{}.txt".format(suffix), 'w')

nmonths = (END_YEAR - START_YEAR) * 12 - (START_MONTH - 1) + END_MONTH
imonths = list(range(nmonths))
curr_month = START_MONTH
imonths = list(range(nmonths))
curr_month = START_MONTH
curr_year = START_YEAR
months = []
years = []
for i in range(nmonths):
    months.append(curr_month)
    years.append(curr_year)
    curr_month += 1
    if curr_month > 12:
        curr_month = 1
        curr_year += 1
navgmonths = (END_AVG_YEAR - START_AVG_YEAR) * 12 \
    - (START_AVG_MONTH - 1) + END_AVG_MONTH

suffix = '_y{}m{}-y{}m{}'.format(day_str(START_YEAR),
                                 day_str(START_MONTH),
                                 day_str(END_YEAR),
                                 day_str(END_MONTH))
if USE_PRESAER:
    suffix += '_presaer'
if TROPICS_ONLY:
    if LAND_TROPICS:
        suffix += '_lndtropics'
    else:
        suffix += '_tropics'
if MIDLATITUDES_ONLY:
    suffix += '_midlats'

log_file = open("plot_monthly_log{}.txt".format(suffix), 'w')
示例#10
0
from e3sm_case_output import day_str, time_str

CASE_NAME = "timestep_presaer_cld_10s_lower_tau2"
CASE_DIR = "/p/lscratchh/santos36/ACME/{}/run".format(CASE_NAME)
OUTPUT_DIR = "/p/lustre2/santos36/timestep_precip/"
NUM_BINS = 101
BINS_BOUNDS = (-2., 3.)  # Bins between 10^-2 and 10^3 mm/day of precip.

bins = np.logspace(BINS_BOUNDS[0], BINS_BOUNDS[1], NUM_BINS - 1)

START_DAY = 3
END_DAY = 15

filename_template = "{}.cam.h0.{}-{}-{}-{}.nc"

first_file_name = filename_template.format(CASE_NAME, "00" + day_str(1),
                                           day_str(1), day_str(1), time_str(0))
first_file = nc4.Dataset(join(CASE_DIR, first_file_name), 'r')
ncol = len(first_file.dimensions['ncol'])
lat = first_file['lat'][:]
lon = first_file['lon'][:]
area = first_file['area'][:]
first_file.close()

prec_vars = ("PRECC", "PRECL", "PRECT")  # "PRECSC", "PRECSL")

ndays = END_DAY - START_DAY + 1

out_file_template = "{}.freq.short.d{}-d{}.nc"

out_file_name = out_file_template.format(CASE_NAME, day_str(START_DAY),