Skip to content

Commit

Permalink
Issue #28: Reducing methods with different names, same functionality …
Browse files Browse the repository at this point in the history
…(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 <[email protected]>
  • Loading branch information
fmalatino and Frank Malatino committed Oct 13, 2023
1 parent e0e7e90 commit fbe0cd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
21 changes: 0 additions & 21 deletions fv3core/pace/fv3core/initialization/init_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down

0 comments on commit fbe0cd5

Please sign in to comment.