From fbe0cd58975f6dc201249467340628e587d5f599 Mon Sep 17 00:00:00 2001 From: fmalatino <142349306+fmalatino@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:12:28 -0400 Subject: [PATCH] Issue #28: Reducing methods with different names, same functionality (continuous issue) (#30) * Testing changes reflected across branches * Undoing changes made in build_gaea_c5.sh * Testing vscode functionality, by adding a change to external_grid branch * Testing vscode functionality, by adding a change to external_grid branch * Edited init_utils.py and initialize_tc.py regarding the overlap in initialize_delp and initialize_edge_pressure functions --------- Co-authored-by: Frank Malatino --- .../pace/fv3core/initialization/init_utils.py | 21 ------------------- .../test_cases/initialize_tc.py | 4 ++-- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/fv3core/pace/fv3core/initialization/init_utils.py b/fv3core/pace/fv3core/initialization/init_utils.py index 15a46d5d..42252e87 100644 --- a/fv3core/pace/fv3core/initialization/init_utils.py +++ b/fv3core/pace/fv3core/initialization/init_utils.py @@ -179,18 +179,6 @@ def horizontally_averaged_temperature(eta): return t_mean -def _initialize_delp(ak, bk, ps, shape): - # TODO: resolve function duplication - delp = np.zeros(shape) - delp[:, :, :-1] = ( - ak[None, None, 1:] - - ak[None, None, :-1] - + ps[:, :, None] * (bk[None, None, 1:] - bk[None, None, :-1]) - ) - - return delp - - def initialize_delp(ps, ak, bk): return ( ak[None, None, 1:] @@ -203,15 +191,6 @@ def initialize_delz(pt, peln): return constants.RDG * pt[:, :, :-1] * (peln[:, :, 1:] - peln[:, :, :-1]) -def _initialize_edge_pressure(delp, ptop, shape): - # TODO: resolve function duplication - pe = np.zeros(shape) - pe[:, :, 0] = ptop - for k in range(1, pe.shape[2]): - pe[:, :, k] = ptop + np.sum(delp[:, :, :k], axis=2) - return pe - - def initialize_edge_pressure(delp, ptop): pe = np.zeros(delp.shape) pe[:, :, 0] = ptop diff --git a/fv3core/pace/fv3core/initialization/test_cases/initialize_tc.py b/fv3core/pace/fv3core/initialization/test_cases/initialize_tc.py index f118557b..33689344 100644 --- a/fv3core/pace/fv3core/initialization/test_cases/initialize_tc.py +++ b/fv3core/pace/fv3core/initialization/test_cases/initialize_tc.py @@ -535,8 +535,8 @@ def init_tc_state( # for now, take from metric terms ak = _define_ak() bk = _define_bk() - delp = init_utils._initialize_delp(ak, bk, ps, shape) - pe = init_utils._initialize_edge_pressure(delp, tc_properties["ptop"], shape) + delp = init_utils.initialize_delp(ps, ak, bk) + pe = init_utils.initialize_edge_pressure(delp, tc_properties["ptop"]) peln = np.log(pe) pk, pkz = init_utils.initialize_kappa_pressures(pe, peln, tc_properties["ptop"])