Skip to content

Commit

Permalink
pre-commit compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
lee1043 committed Oct 26, 2023
1 parent 1401dc2 commit d29cb53
Show file tree
Hide file tree
Showing 87 changed files with 1,592 additions and 843 deletions.
5 changes: 3 additions & 2 deletions pcmdi_metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plog.addHandler(ch)
plog.setLevel(LOG_LEVEL)
from . import io # noqa
#from . import pcmdi # noqa
#from . import mean_climate # noqa

# from . import pcmdi # noqa
# from . import mean_climate # noqa
from .version import __git_sha1__, __git_tag_describe__, __version__ # noqa
41 changes: 31 additions & 10 deletions pcmdi_metrics/cloud_feedback/cloud_feedback_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
with open(input_files_json) as f:
ncfiles = json.load(f)
else:
print('Warning: input files were not explicitly given. They will be searched from ', path)
print(
"Warning: input files were not explicitly given. They will be searched from ",
path,
)

for exp in exps:
filenames[exp] = dict()
Expand Down Expand Up @@ -169,15 +172,33 @@
output_dict["RESULTS"][model] = OrderedDict()
output_dict["RESULTS"][model][variant] = OrderedDict()
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"] = OrderedDict()
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["high_cloud_altitude"] = assessed_cld_fbk[0]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["tropical_marine_low_cloud"] = assessed_cld_fbk[1]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["tropical_anvil_cloud_area"] = assessed_cld_fbk[2]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["land_cloud_amount"] = assessed_cld_fbk[3]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["middle_latitude_marine_low_cloud_amount"] = assessed_cld_fbk[4]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["high_latitude_low_cloud_optical_depth"] = assessed_cld_fbk[5]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["implied_unassessed"] = assessed_cld_fbk[6]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["sum_of_assessed"] = assessed_cld_fbk[7]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"]["total_cloud_feedback"] = assessed_cld_fbk[8]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"high_cloud_altitude"
] = assessed_cld_fbk[0]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"tropical_marine_low_cloud"
] = assessed_cld_fbk[1]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"tropical_anvil_cloud_area"
] = assessed_cld_fbk[2]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"land_cloud_amount"
] = assessed_cld_fbk[3]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"middle_latitude_marine_low_cloud_amount"
] = assessed_cld_fbk[4]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"high_latitude_low_cloud_optical_depth"
] = assessed_cld_fbk[5]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"implied_unassessed"
] = assessed_cld_fbk[6]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"sum_of_assessed"
] = assessed_cld_fbk[7]
output_dict["RESULTS"][model][variant]["assessed_cloud_feedback"][
"total_cloud_feedback"
] = assessed_cld_fbk[8]
output_dict["RESULTS"][model][variant]["clim_cloud_rmse"] = climo_cld_rmse
output_dict["RESULTS"][model][variant]["cloud_feedback_rmse"] = cld_fbk_rmse
output_dict["RESULTS"][model][variant]["equilibrium_climate_sensitivity"] = ecs
Expand Down
1 change: 0 additions & 1 deletion pcmdi_metrics/cloud_feedback/lib/argparse_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def AddParserArgument():

P = CDPParser(
default_args_file=[],
description="Cloud feedback metrics",
Expand Down
7 changes: 4 additions & 3 deletions pcmdi_metrics/cloud_feedback/lib/cal_CloudRadKernel_xr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
# to expert-assessed values from Sherwood et al (2020)
# =============================================

from datetime import date

# IMPORT STUFF:
import cftime
import numpy as np
import xarray as xr
import xcdat as xc
import numpy as np
from global_land_mask import globe
from datetime import date

# =============================================
# define necessary information
Expand Down Expand Up @@ -190,7 +191,7 @@ def get_CRK_data(filepath):
###########################################################################
def get_kernel_regrid(ctl):
# Read in data and map kernels to lat/lon

f = xc.open_mfdataset(datadir + "cloud_kernels2.nc", decode_times=False)
f = f.rename({"mo": "time", "tau_midpt": "tau", "p_midpt": "plev"})
f["time"] = ctl["time"].copy()
Expand Down
41 changes: 25 additions & 16 deletions pcmdi_metrics/cloud_feedback/lib/cld_fbks_ecs_assessment_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"""

import json
import string
import os
import string
from datetime import date

import matplotlib as mpl
Expand All @@ -17,7 +17,7 @@
HEIGHT = 0.45

# ######################################################
# DEFINE COLORS FOR ECS COLORBAR
# DEFINE COLORS FOR ECS COLORBAR
# ######################################################
cmap = plt.cm.RdBu_r # define the colormap
# extract all colors from the .jet map
Expand Down Expand Up @@ -75,7 +75,6 @@

# ######################################################
def get_expert_assessed_fbks():

# ######################################################
# ############# WCRP ASSESSMENT VALUES #################
# ######################################################
Expand Down Expand Up @@ -272,7 +271,6 @@ def get_fbks(cld_fbks, obsc_cld_fbks, cld_errs, ecs_dict):

# ######################################################
def get_gcm_assessed_fbks(fbk_dict, obsc_fbk_dict):

# dictionary is structured: [region][sfc][sec][name]

assessed = []
Expand Down Expand Up @@ -364,7 +362,6 @@ def get_gcm_assessed_fbks(fbk_dict, obsc_fbk_dict):

# ######################################################
def get_gcm_cld_errs(err_dict, name):

# dictionary is structured: [region][sfc][sec][name]

DATA = []
Expand Down Expand Up @@ -403,7 +400,6 @@ def get_gcm_cld_errs(err_dict, name):

# ######################################################
def get_unassessed_fbks(fbk_dict, obsc_fbk_dict):

# dictionary is structured: [region][sfc][sec][name]

fbk_names = []
Expand Down Expand Up @@ -651,7 +647,6 @@ def label_models(ax, models5, models6):

# ######################################################
def plot_expert():

(expert_cld_fbks, err_expert_cld_fbks, fbk_names) = get_expert_assessed_fbks()
LN = len(fbk_names)

Expand Down Expand Up @@ -880,10 +875,15 @@ def static_plot(assessed, ecs, models, fbk_names, gen, fig, gs):

# ######################################################
def make_all_figs(
cld_fbks6, obsc_cld_fbks6, cld_errs6, ecs_dict56, newmod,
figdir=None, datadir=None,
debug=False):

cld_fbks6,
obsc_cld_fbks6,
cld_errs6,
ecs_dict56,
newmod,
figdir=None,
datadir=None,
debug=False,
):
# Set a unique marker for your new model
MARK[newmod] = "<"

Expand Down Expand Up @@ -998,7 +998,9 @@ def make_all_figs(
# new axis for labeling all models
ax = plt.subplot(gs[:10, 10:12])
label_models(ax, models5, models6)
plt.savefig(os.path.join(figdir, "WCRP_assessed_cld_fbks_amip-p4K.png"), bbox_inches="tight")
plt.savefig(
os.path.join(figdir, "WCRP_assessed_cld_fbks_amip-p4K.png"), bbox_inches="tight"
)
if debug:
print("make_all_figs: WCRP_assessed_cld_fbks_amip-p4K.png done")

Expand Down Expand Up @@ -1030,7 +1032,10 @@ def make_all_figs(
# new axis for labeling all models
ax = plt.subplot(gs[:10, 10:12])
label_models(ax, models5, models6)
plt.savefig(os.path.join(figdir, "WCRP_unassessed_cld_fbks_amip-p4K.png"), bbox_inches="tight")
plt.savefig(
os.path.join(figdir, "WCRP_unassessed_cld_fbks_amip-p4K.png"),
bbox_inches="tight",
)
if debug:
print("make_all_figs: WCRP_unassessed_cld_fbks_amip-p4K.png done")

Expand Down Expand Up @@ -1277,8 +1282,9 @@ def make_all_figs(
)
cb.ax.tick_params(labelsize=14)
ax2.set_ylabel(r"$\mathrm{E_{NET}}$", size=14)
plt.savefig(os.path.join(
figdir, "WCRP_assessed_RMSE_v_cldfbk2_amip-p4K.png"), bbox_inches="tight"
plt.savefig(
os.path.join(figdir, "WCRP_assessed_RMSE_v_cldfbk2_amip-p4K.png"),
bbox_inches="tight",
)

# #####################################################
Expand Down Expand Up @@ -1402,7 +1408,10 @@ def make_all_figs(
plt.title("b", fontsize=16, loc="left")
plt.ylim(0.04, 0.15)
plt.xlim(0.60, 1.65)
plt.savefig(os.path.join(figdir, "WCRP_totcldfbks2_v_E_NET_amip-p4K.png"), bbox_inches="tight")
plt.savefig(
os.path.join(figdir, "WCRP_totcldfbks2_v_E_NET_amip-p4K.png"),
bbox_inches="tight",
)

# ######################################################
# PRINT OUT THE TABLE OF EVERYTHING:
Expand Down
Loading

0 comments on commit d29cb53

Please sign in to comment.